Nginx 修改 上游服务器的 重定向
用户投稿 学习笔记 20阅读
语法:proxy_redirect [ default|off|redirect replacement ];默认:proxy_redirect default;配置块(使用的字段):http、server、location 当上游服务器返回的响应是重定向或刷新请求(如HTTP响应码是301或者302)时,proxy_redirect可以重设HTTP头部的location或refresh字段。
location /login { proxy_pass http://target_servers/login ; }如果需要修改从被代理服务器传来的应答头中的"Location"和"Refresh"字段,这时候就可以用proxy_redirect这个指令设置。
示例:
假设被代理服务器返回Location字段为http://localhost:8000/kevin/some/uri/ proxy_redirect http://localhost:8000/kevin/ http://frontend/one/; 将Location字段重写为http://frontend/one/some/uri/,客户端会请求http://frontend/one/some/uri/,而不是http://localhost:8000/kevin/some/uri/标签: