nginx 反向代理之 proxy_pass的實(shí)現(xiàn)
格式很簡單: proxy_pass URL;
其中URL包含:傳輸協(xié)議(http://, https://等)、主機(jī)名(域名或者IP:PORT)、uri。
示例如下:
proxy_pass http://www.xxx.com/; proxy_pass http://192.168.200.101:8080/uri; proxy_pass unix:/tmp/www.sock;
對(duì)于proxy_pass的配置有幾種情況需要注意:
假設(shè)server_name為www.xxx.com
當(dāng)請(qǐng)求http://www.xxx.com/aming/a.html的時(shí)候,以上示例分別訪問的結(jié)果是
示例1:
location /aming/ { proxy_pass http://192.168.1.10; ... }
結(jié)果1:http://192.168.1.10/aming/a.html
示例2:
location /aming/ { proxy_pass http://192.168.1.10/; ... }
結(jié)果2:http://192.168.1.10/a.html
示例3:
location /aming/ { proxy_pass http://192.168.1.10/linux/; ... }
結(jié)果3:http://192.168.1.10/linux/a.html
示例4:
location /aming/ { proxy_pass http://192.168.1.10/linux; ... }
結(jié)果4:http://192.168.1.10/linuxa.html
總結(jié):
為了方便記憶和規(guī)范配置,建議所有的 proxy_pass 后的url都以“/”結(jié)尾。
proxy_pass http://192.168.1.10/linux/;
到此這篇關(guān)于nginx 反向代理之 proxy_pass的實(shí)現(xiàn)的文章就介紹到這了,更多相關(guān)nginx 反向代理 proxy_pass內(nèi)容請(qǐng)搜索本站以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持本站!
版權(quán)聲明:本站文章來源標(biāo)注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請(qǐng)保持原文完整并注明來源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非www.sddonglingsh.com所屬的服務(wù)器上建立鏡像,否則將依法追究法律責(zé)任。本站部分內(nèi)容來源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來,僅供學(xué)習(xí)參考,不代表本站立場(chǎng),如有內(nèi)容涉嫌侵權(quán),請(qǐng)聯(lián)系alex-e#qq.com處理。