nginx在redirect時關閉自動添加後端端口和server_name

原因: 

通過端口映射時,nginx會自動添加內網端口,修改路徑導致路徑訪問出錯;


解決: 


在server裏面加入port_in_redirect off;關閉自動添加端口


 > port_in_redirect off


語法:port_in_redirect on | off;

默認值:port_in_redirect on;

上下文:http, server, location


如果要添加端口的話,設置:

 proxy_set_header Host $host:端口號;



保持請求url中的域名,而非使用後端的server_name進行跳轉:


> server_name_in_redirect off


語法:server_name_in_redirect on | off;

默認值:server_name_in_redirect off;

上下文:http, server, location







發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章