源地址 :html
https://www.zifangsky.cn/917.htmlnginx
此時proxy_pass後面的路徑必須拼接location的路徑:服務器
1
2
3
4
5
6
7
8
|
location /sta
{
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;
proxy_pass http://192.168.1.31/sta;
}
|
注:這裏也能夠寫成:「proxy_pass http://192.168.1.31/sta/;」。固然,不推薦使用上面這種寫法cookie
此時proxy_pass後面的路徑須要分爲如下四種狀況討論:app
1
2
3
4
5
6
7
8
|
location /sta/
{
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;
proxy_pass http://192.168.1.31;
}
|
1
2
3
4
5
6
7
8
|
location /sta/
{
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;
proxy_pass http://192.168.1.31/;
}
|
1
2
3
4
5
6
7
8
|
location /sta/
{
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;
proxy_pass http://192.168.1.31/abc;
}
|
1
2
3
4
5
6
7
8
|
location /sta/
{
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;
proxy_pass http://192.168.1.31/abc/;
}
|
附:在nginx上面配置APK文件下載路徑:spa
1
2
3
4
5
6
7
8
9
|
location ^~ /h5/appdownload/
{
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;
proxy_pass http://192.168.1.31/;
proxy_set_header Cookie $http_cookie;
}
|
每次更新apk文件,只須要上傳新的apk文件到192.168.1.31服務器,而後再更新對外的下載地址爲http://test.com/h5/appdownload/newName.apk便可,並不須要更改nginx的任何配置code