您的位置:首页 > 运维架构 > Nginx

Nginx配置proxy_pass时的注意事项

2014-07-17 23:29 666 查看
下面分别用http://192.168.1.10/test/test.php进行访问:

1. location /test/ {

proxy_pass http://192.168.1.11;
}

会被代理到 http://192.168.1.11/test/test.php 这个url

2. location /test/ {

proxy_pass http://192.168.1.11/;
}

会被代理到 http://192.168.1.11/test.php 这个url

上面两种配置,区别只在于proxy_pass转发的路径后是否带 “/”。

在nginx中配置proxy_pass时,当在后面的url加上了/,相当于是绝对根路径,则nginx不会把location中匹配的路径部分代理走;如果没有/,则会把匹配的路径部分也给代理走。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: