1、在nginx中配置proxy_pass时,当在后面的url加上了/,nginx不会把location中匹配到的路径往后转递,而是扔掉;
2、如果没有/,则会把匹配到的路径部分也给往后转递。
举例
使用http://192.168.0.2/proxy/test.html 进行访问
1、端口81后带/
location /proxy/ {
proxy_pass http://127.0.0.1:81/
}
不会代理匹配的路径,即proxy被扔掉,不会往后转递,所以最终会被代理到: http://127.0.0.1:81/test.html
2、端口81后面不带/
location /proxy/ {
proxy_pass http://127.0.0.1:81;
}
会代理匹配的路径,即带上proxy往后转递,所以最终会被代理到: http://127.0.0.1:81/proxy/test.html