Nginx配置proxy_pass转发的/路径问题

在nginx中配置proxy_pass时,如果是按照^~匹配路径时,要注意proxy_pass后的url最后的/,当加上了/,相当于是绝对根路径,则nginx不会把location中匹配的路径部分代理走;如果没有/,则会把匹配的路径部分也给代理走。

例如访问http://guuyoog.com/a/index.html

location ^~ /a/ 

proxy_pass http://test.com/
}

-->  http://test.com/index.html

location ^~ /a/ 

proxy_pass http://test.com
}

-->  http://test.com/a/index.html

猜你喜欢

转载自www.cnblogs.com/guuyoog/p/9216451.html