Adding custom HTTP headers to nginx X-Accel-Redirect Adding custom HTTP headers to nginx X-Accel-Redirect ruby-on-rails ruby-on-rails

Adding custom HTTP headers to nginx X-Accel-Redirect


Use add_header Content-MD5 $upstream_http_content_md5;

Since X-Accel-Redirect causes internal redirect nginx will not send returned headers, but it will keep them in $upstream_http_... variables. So you could use them.


I've tried accepted answer and it doesn't work for me. But this works:

 set $authorization "$upstream_http_authorization"; proxy_set_header Authorization $authorization; # Pass on secret from back end

(copy-pasted from this article https://clubhouse.io/developer-how-to/how-to-use-internal-redirects-in-nginx/)

It's interesting that it's important to extract variable. This does not work for me:

 proxy_set_header Authorization "$upstream_http_authorization";