在nginx中配置proxy_pass代理轉發時,如果在proxy_pass后面的url加/,表示絕對根路徑;如果沒有/,表示相對路徑,把匹配的路徑部分也給代理走, 假設下面四種情況分別用 http://192.168.1.1/proxy/test.html 進行訪問, 第一種:location /proxy/ { proxy_pass http://127.0.0.1/;}代理到URL:http://127.0.0.1/test.html 第二種(相對于第一種,最后少一個 / )location /proxy/ { proxy_pass http://127.0.0.1;}代理到URL:http://127.0.0.1/proxy/test.html 第三種:location /proxy/ { proxy_pass http://127.0.0.1/aaa/;}代理到URL:http://127.0.0.1/aaa/test.html 第四種(相對于第三種,最后少一個 / )location /proxy/ { proxy_pass http://127.0.0.1/aaa;}代理到URL:http://127.0.0.1/aaatest.html
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/5361.html
標籤:其他
上一篇:nginx配置訪問本地靜態資源
下一篇:陣列的參考與參考的陣列
