Proxy pass remote_user with nginx

Thomas picture Thomas · Jul 31, 2017 · Viewed 8.7k times · Source

I have a firewall that is the SSL terminator and sets the remote_user header. This header should be passed onto an application, however we have an nginx proxy sitting in the middle.

Browser over SSL -> Firewall proxy -> Nginx proxy -> App

I cannot for the life of me figure out how to pass the remote_user header to the App from the Firewall. Nginx seems to swallow it. $remote_user doesn't have it (which makes sense). $http_remote_user doesn't have it (which doesn't make sense). I tried to find it in $proxy_add_* but couldn't.

How do I proxy pass the remote_user header when the SSL terminator isn't nginx?

EDIT1: Other things I have tried:

proxy_pass_request_headers on;
proxy_pass_header remote_user;
proxy_set_header other_user $http_remote_user;

proxy_pass http://scooterlabs.com/echo;

Answer

gargsms picture gargsms · Jul 31, 2017

You need to use a combination of proxy_pass_request_headers on and underscores_in_headers on since your header contains an underscore.

underscores_in_headers needs to be placed in your http block.

See: http://nginx.org/en/docs/http/ngx_http_core_module.html#underscores_in_headers

OLD ANSWER

You are looking for proxy_pass_header

See: Module ngx_http_proxy_module