We are using nginx as a proxy for a java application (both in docker containers, but that's probably not relevant). When we try to reach the java application via a rest client a specific header, SM_USER gets lost within the proxy-pass. Strange thing is: if we use CURL or PHP Zend Framework or a Firefox rest add-on to do a request the proxy pass configuration works. But if we use a Java Spring rest client or soapUI the header gets lost. If we bypass the proxy it works from Java/soapUI as well.
We use the following nginx configuration:
server {
listen 80;
server_name devrest.example.com;
root /devrestserver;
underscores_in_headers on;
location / {
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass_request_headers on;
proxy_pass http://devrest:8080;
}
}
As you can see we use underscores_in_headers on; and explicitly set proxy_pass_request_headers on; in the configuration.
A tcpdump before nginx takes over shows us the SM_USER header is reaching the server:
GET /resource/RoomType/ HTTP/1.1
Accept: text/plain, application/json, application/*+json, */*
Content-Type: application/json
SM_USER: atnqtjrce0cjfve0fbjbsov2ff
Accept-Language: de
User-Agent: Java/1.7.0_71
Host: devrest.example.com
Connection: keep-alive
A tcpdump within the docker network (between the nginx proxy and the application) shows that the header dissapeared:
GET /resource/RoomType/ HTTP/1.0
X-Forwarded-Host: devrest.example.com
X-Forwarded-Server: devrest.example.com
X-Forwarded-For: 78.132.28.121
Host: devrest:8080
Connection: close
Accept: text/plain, application/json, application/*+json, */*
Content-Type: application/json
Accept-Language: de
User-Agent: Java/1.7.0_71
I also tried
proxy_pass_header SM_USER;
as recommended at the following link nginx passing back custom header
and I tried explicitly renaming the header by using the following:
proxy_set_header X-siteminderuser $http_sm_user;
which worked totally fine when doing the CURL request but didn't show up at all using Java. It seems the SM_USER is filtered out even before $http_... variable takes effect.
If I rename the header in the java rest client and use
proxy_set_header SM_USER $http_x_siteminder_user;
it gets through but unfortunately it is very hard to get this changed in the original java rest client (which is a software from another company), so I would really appreciate any suggestions how I could get the SM_USER header passed through the nginx proxy. Can you help us please.