nginx location ,proxy_pass 后面的url 加与不加/的区别

location /test {
	proxy_pass http://127.0.0.1:8888;
}

location /test/ {
	proxy_pass http://127.0.0.1:8888/;
}

Location:
location进行的是模糊匹配

如果test后不带/
表示会拦截 如/test /test01 /testxxxxx 这一类请求,只要是以test开头的请求都会被拦截

proxy_pass:
proxy_pass时,当在后面的url加上了/,相当于是绝对根路径,则nginx不会把location中匹配的路径部分代理走;如果没有/,则会把匹配的路径部分也给代理走。

附加

通过这种方法的 POST 数据会消失,因为相当于重新发起了一次get请求

发布了48 篇原创文章 · 获赞 56 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/zhetmdoubeizhanyong/article/details/100127349