代碼解釋
1.1 http:www.baidu.test.com默認(rèn)是80,訪問(wèn)“/”利用反向代理,然后訪問(wèn)本地8083;
1.2 8083代表本地的前端工程訪問(wèn)地址,前端需要訪問(wèn)后臺(tái)數(shù)據(jù),”/”,繼續(xù)代理到后臺(tái)地址9803;
1.3 這樣就做到了只要開(kāi)通80端口就可以完成多個(gè)端口訪問(wèn)。
1.4 root配置可以是絕對(duì)路徑,也可是相對(duì)路徑。
server {
listen 80;
server_name www.baidu.test.com;#你要填寫(xiě)的域名,多個(gè)用逗號(hào)隔開(kāi)
location / {
proxy_pass http://localhost:8083;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
root /app/esop_web/esopschool;
index index.html;
try_files $uri $uri/ /index.html;
}
location /rest{
proxy_pass http://localhost:9803;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。