nginx proxy_pass末尾神奇的/
生活随笔
收集整理的這篇文章主要介紹了
nginx proxy_pass末尾神奇的/
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
http://otherserver;和http://otherserver/;有什么區(qū)別呢?
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
前者配置,在后端的機(jī)器,收到的是http://neverstay.com/service/add.php
后者配置,在后端的機(jī)器,收到的是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
前者配置,在后端的機(jī)器,收到的是http://neverstay.com/service/add.php
后者配置,在后端的機(jī)器,收到的是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;
}
總結(jié)
以上是生活随笔為你收集整理的nginx proxy_pass末尾神奇的/的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: c++ 深复制
- 下一篇: Mysql 从库跳过