nginx proxy_pass末尾神奇的/
生活随笔
收集整理的这篇文章主要介绍了
nginx proxy_pass末尾神奇的/
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
http://otherserver;和http://otherserver/;有什么区别呢?
location /service/ {
proxy_pass http://otherserver;
proxy_next_upstream error timeout invalid_header http_500 http_503 http_404;
}
location /service/ {
proxy_pass http://otherserver/;
proxy_next_upstream error timeout invalid_header http_500 http_503 http_404;
}
同样访问:http://neverstay.com/service/add.php
前者配置,在后端的机器,收到的是http://neverstay.com/service/add.php
后者配置,在后端的机器,收到的是http://neverstay.com/add.php
如果换成下面这样,会报错:
location ~ ^/(service)/ {
proxy_pass http://otherserver/;
proxy_next_upstream error timeout invalid_header http_500 http_503 http_404;
}
"proxy_pass" may not have URI part in location given by regular expression, or inside named location, or inside the "if" statement, or inside the "limit_except" block in nginx.conf:
但是,这样就没问题了:
location ~ ^/(service)/ {
proxy_pass http://otherserver;
proxy_next_upstream error timeout invalid_header http_500 http_503 http_404;
}
location /service/ {
proxy_pass http://otherserver;
proxy_next_upstream error timeout invalid_header http_500 http_503 http_404;
}
location /service/ {
proxy_pass http://otherserver/;
proxy_next_upstream error timeout invalid_header http_500 http_503 http_404;
}
同样访问:http://neverstay.com/service/add.php
前者配置,在后端的机器,收到的是http://neverstay.com/service/add.php
后者配置,在后端的机器,收到的是http://neverstay.com/add.php
如果换成下面这样,会报错:
location ~ ^/(service)/ {
proxy_pass http://otherserver/;
proxy_next_upstream error timeout invalid_header http_500 http_503 http_404;
}
"proxy_pass" may not have URI part in location given by regular expression, or inside named location, or inside the "if" statement, or inside the "limit_except" block in nginx.conf:
但是,这样就没问题了:
location ~ ^/(service)/ {
proxy_pass http://otherserver;
proxy_next_upstream error timeout invalid_header http_500 http_503 http_404;
}
总结
以上是生活随笔为你收集整理的nginx proxy_pass末尾神奇的/的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: c++ 深复制
- 下一篇: jquery css 定义背景不重复