Reputation: 1
I'm configuring an application that will authenticate a user, and then set the X-Accel-Redirect
header and a private api key, Foo
(for testing purposes), that will be passed on to the proxied endpoint.
I'm setting the private api key as a header in the authenticating application, and have the following location block in my nginx configuration file. How do I set the header to the proxied application based on what the upsteam server sets? I've also tried using $http_foo
and $sent_http_foo
. Currently, the Foo response header is never set for the proxy.
location ~* ^/redirect {
internal;
resolver 8.8.8.8;
proxy_ssl_server_name on;
add_header Foo $upstream_http_foo;
set $my_host "requestb.in";
set $my_uri "a_test_uri";
proxy_pass http://$my_host/$my_uri;
}
Upvotes: 0
Views: 2719
Reputation: 3229
The directive to use is proxy_set_header, so in your case:
proxy_set_header Foo $http_api_key; # assuming a "API-Key" header incoming
As a general rule, any settings you intend to apply to your communication with an upstream will be prefixed with proxy_
Upvotes: 3