proxy_pass 规则
Note that in the first example above, the address of the proxied server is followed by a URI, /link/. If the URI is specified along with the address, it replaces the part of the request URI that matches the location parameter. For example, here the request with the /some/path/page.html URI will be proxied to http://www.example.com/link/page.html. If the address is specified without a URI, or it is not possible to determine the part of URI to be replaced, the full request URI is passed (possibly, modified).
引自:https://docs.nginx.com/nginx/admin-guide/web-server/reverse-proxy/
例如本地80端口Nginx代理8080端口服务,同样是访问 http://127.0.0.1/test/hello
配置1:
location /test/ {
proxy_pass http://127.0.0.1:8080;
}
会访问被代理服务的: http://127.0.0.1:8080/test/hello
配置2:
location /test/ {
proxy_pass http://127.0.0.1:8080/;
}
会访问被代理服务的: http://127.0.0.1:8080/hello