标签:127.0 http 0.1 nginx proxy pass location
If the proxy_pass directive is specified with a URI, then when a request is passed to the server, the part of a normalized request URI matching the location is replaced by a URI specified in the directive:
location /name/ {
proxy_pass http://127.0.0.1/remote/;
}
If proxy_pass is specified without a URI, the request URI is passed to the server in the same form as sent by a client when the original request is processed, or the full normalized request URI is passed when processing the changed URI:
location /some/path/ {
proxy_pass http://127.0.0.1;
}
In some cases, the part of a request URI to be replaced cannot be determined:
When location is specified using a regular expression, and also inside named locations.
In these cases, proxy_pass should be specified without a URI.
总结起来就是 proxy_pass 过程中会 使用 proxy_pass 中special 的url 替换命中的url,但是如果location 中存在rewrite 或者 要使用变量 那proxy_pass 中special 的url将不再生效
测试文件
server {
server_name songtest.com;
#access_log /tmp/songtest.log main;
listen 80 ;
location / {
proxy_pass http://127.0.0.1:8080/zz1;
}
location /app {
proxy_pass http://127.0.0.1:8080;
}
# songtest.com/app/1 http://127.0.0.1:8080/app/1
location /app2 {
proxy_pass http://127.0.0.1:8080/zz2;
}
# songtest.com/app2/1 http://127.0.0.1:8080/zz2/1
location ^~ /app3 {
proxy_pass http://127.0.0.1:8080/zz2;
}
# songtest.com/app3/1 http://127.0.0.1:8080/zz2/1
location /app5 {
rewrite (.*) /users?name=$1 break;
proxy_pass http://127.0.0.1/useless;
}
# songtest.com/app5/1 http://127.0.0.1:8080/users?name=/app5/1
}
openresty 中使用的切忌
以上配置在 openresty 添加lua配置后失效
标签:127.0,http,0.1,nginx,proxy,pass,location 来源: https://www.cnblogs.com/leleyao/p/16436369.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。