nginx 的proxy_pass 基本設置問題

nginx 的proxy_pass 基本設置問題

    曾在網上看到一些問題,比如 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之後,跳轉行爲可能會令你感到莫名其妙,要有充分的思想準備。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章