nginx 反向代理之 proxy_pass的實現(xiàn)
格式很簡單: proxy_pass URL;
其中URL包含:傳輸協(xié)議(http://, https://等)、主機名(域名或者IP:PORT)、uri。
示例如下:
proxy_pass http://www.xxx.com/; proxy_pass http://192.168.200.101:8080/uri; proxy_pass unix:/tmp/www.sock;
對于proxy_pass的配置有幾種情況需要注意:
假設(shè)server_name為www.xxx.com
當請求http://www.xxx.com/aming/a.html的時候,以上示例分別訪問的結(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的實現(xiàn)的文章就介紹到這了,更多相關(guān)nginx 反向代理 proxy_pass內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
- Nginx服務(wù)器的反向代理proxy_pass配置方法講解
- Nginx代理proxy pass配置去除前綴的實現(xiàn)
- nginx配置中proxy_pass反向代理502的bug記錄
- nginx配置proxy_pass代理轉(zhuǎn)發(fā)時報404問題
- nginx反向代理proxy_pass遇到的死循環(huán)問題
- nginx代理參數(shù)proxy_pass的實現(xiàn)
- Nginx?反向代理緩存(proxy_cache)的實現(xiàn)
- nginx反向代理proxy_set_header
- Nginx Proxy Manager輕松搭建反向代理的實現(xiàn)
- Nginx Proxy 代理測試的實現(xiàn)
相關(guān)文章
nginx和lvs各自的優(yōu)劣以及適合的使用環(huán)境
這篇文章主要介紹了nginx和lvs各自的優(yōu)劣以及適合的使用環(huán)境,幫助大家選擇符合需求的服務(wù)器,感興趣的朋友可以了解下2020-10-10