How to add a response header on nginx when using proxy_pass?

前端 未结 5 1786
太阳男子
太阳男子 2020-12-07 11:19

I want to add a custom header for the response received from the server behind nginx.

While add_header works for nginx-processed responses, it does noth

5条回答
  •  佛祖请我去吃肉
    2020-12-07 12:10

    As oliver writes:

    add_header works as well with proxy_pass as without.

    However, as Shane writes, as of Nginx 1.7.5, you must pass always in order to get add_header to work for error responses, like so:

    add_header  X-Upstream  $upstream_addr always;
    

提交回复
热议问题