Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm using the nginx X-Accel-Redirect feature where a proxied backend (A) can "internally redirect" nginx to reprocess a new URI (B) as if that were the one originally given by the client browser.

It works great in making request B (also proxied)and returning B's resulting headers back to the client browser. So far so good.

But also I have some headers from A which I'd like to pass along too. In other words, merge a handful of headers from A in with the result from B.

How can I do this? I've tried

add_header  X-My-Header  $http_x_my_header;

But that $http_x_my_header variable is empty, presumably because the original request didn't have it. I've also tried $upstream_x_my_header but that's empty too. I've tried things like proxy_pass_header X-My-Header; but no.

share|improve this question

1 Answer 1

According to nginx manual for proxy_set_header:

If value is empty string, then header will not be sent to upstream.

Try using proxy_set_header X-My-Header "OK" or perhaps a variable you'd like to use as value. That should pass it to the proxy as well as the user.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.