Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Proxy pass remote_user with nginx

Tags:

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;
like image 846
Thomas Avatar asked Jul 31 '17 19:07

Thomas


People also ask

Can I use NGINX as a forward proxy?

NGINX was initially designed as a reverse proxy server. However, with continuous development, NGINX also serves as one of the options to implement the forward proxy.

What is proxy pass in NGINX?

The proxy_pass setting makes the Nginx reverse proxy setup work. The proxy_pass is configured in the location section of any virtual host configuration file. To set up an Nginx proxy_pass globally, edit the default file in Nginx's sites-available folder.

Does NGINX support proxy protocol?

The PROXY protocol enables NGINX and NGINX Plus to receive client connection information passed through proxy servers and load balancers such as HAproxy and Amazon Elastic Load Balancer (ELB). With the PROXY protocol, NGINX can learn the originating IP address from HTTP, SSL, HTTP/2, SPDY, WebSocket, and TCP.

Is NGINX forward or reverse proxy?

It's fast, lightweight and responsible for hosting some of the biggest sites on the internet. Nginx is often used as a load balancer, a reverse proxy, and an HTTP Cache, among other uses. In this tutorial, we are focusing on learning how to use it as a forward proxy for any requested location.


1 Answers

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

like image 96
gargsms Avatar answered Oct 11 '22 13:10

gargsms