nginx 的proxy_pass 基本设置问题

来源:互联网 发布:看电影用什么软件 编辑:程序博客网 时间:2024/04/30 15:59

    曾在网上看到一些问题,比如 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之后,跳转行为可能会令你感到莫名其妙,要有充分的思想准备。
原创粉丝点击