proxy_redirect
語法:proxy_redirect [ default|off|redirect replacement ]
默認值:proxy_redirect default
使用字段:http, server, location
如果需要修改從被代理服務器傳來的應答頭中的”Location”和”Refresh”字段,可以用這個指令設置。
假設被代理服務器返回Location字段爲: http://localhost:8000/two/some/uri/
這個指令:
proxy_redirect http://localhost:8000/two/ http://frontend/one/;
將Location字段重寫爲http://frontend/one/some/uri/。
在代替的字段中可以不寫服務器名:
proxy_redirect http://localhost:8000/two/ /;
這樣就使用服務器的基本名稱和端口,即使它來自非80端口。