最近做项目,需要实现下面功能。
1. 应用服务器上的nas上挂载有html,images等文件是骑士岗前培训考试,骑士登陆app侯需要通过互联网访问应用服务器上的岗前培训考试页面。
2.app应用下载地址的页面放在nas上,通过微信扫描二维码需要访问该页面,点击页面上的安卓下载需要访问应用服务器上的接口提供app应用信息【应用名称,大小,版本信息】。
基于上面需要,想到了通过nginx的反向代理来满足以上条件,附上nginx的开发环境配置。
server { listen 8080; server_name localhost; index index.html index.htm index.php; underscores_in_headers on; charset utf-8; root /nfsc/O2O_CDS_CORE; location / { proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location /ops/h5Download/ { proxy_pass http://o2o-cds-core.sit.sf-express.com/ops/h5Download/; proxy_redirect off; proxy_set_header Host $host; } location ~ .*\.(html|htm|gif|jpg|jpeg|png|bmp|swf|flv|mp3|mp4|js|css)$ { #root /nfsc/O2O_CDS_CORE; } location = /stats { stub_status on; access_log off; allow 10.111.0.0/16; allow 10.116.0.0/16; allow 10.0.0.0/8; allow all; #deny all; } }