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

nginx 的proxy_pass 基本设置问题GOOD

2014-03-29 14:17 375 查看
曾在网上看到一些问题,比如 nginx 的proxy_pass后面的地址加“/”与不加“/”有区别。
   参看nginx英文文档后,发现:

If it is necessary to transmit URI in the unprocessed form then directive proxy_pass should be used without URI part:

location  /some/path/ {

  proxy_pass   http://127.0.0.1;

}

大概意思就是说,如果你不想nginx对你的URI请求有任何形式的修改,那么,proxy_pass的配置中就不应该有任何URI部分。

举个例子,nginx服务器IP为10.0.0.20,它的配置不含URI:

location /first/second/ {

        proxy_pass http://10.0.0.30:90;
}

那么,

原:     http://10.0.0.20/first/second/test.html
转:http://10.0.0.30:90/first/second/test.html


 割一下,如果配置成含URI:

location /first/second/ {

proxy_pass http://10.0.0.30:90/myuri;
}

那么,

原: http://10.0.0.20/first/second/test.html
转:http://10.0.0.30:90/myuri/test.html


简单地说,配置了URI之后,跳转行为可能会令你感到莫名其妙,要有充分的思想准备。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  nginx proxy_pass