场景
- nginx负载均衡
参考资料
用法
语法
proxy_pass URL;
proxy_pass http://localhost:8000/uri/;
proxy_pass http://unix:/tmp/backend.socket:/uri/;
Sets the protocol and address of a proxied server and an optional URI to which a location should be mapped. As a protocol, “http” or “https” can be specified. The address can be specified as a domain name or IP address, and an optional port:设置代理服务器的协议(https || http) 和address ; 另外URI 是可选的;
如果proxy_pass 如果设置成域名 upstream, 这个域名被解析成几个address 则这个address是被循环调用的路径
location /name/ {
proxy_pass http://127.0.0.1/remote/;
}请求 http://127.0.0.1/name/what.php 实际上访问的是 http://127.0.0.1/remote/what.php
location /name/ {
proxy_pass http://127.0.0.1/remote;
}请求 http://127.0.0.1/name/what.php 实际上访问的是 http://127.0.0.1/remotewhat.php
location /name/ {
proxy_pass http://127.0.0.1;
}请求 http://127.0.0.1/name/what.php 实际上访问的是http://127.0.0.1/name/what.php
location /name/ {
proxy_pass http://127.0.0.1/;
}请求 http://127.0.0.1/name/what.php 实际上访问的是http://127.0.0.1/what.php