Welcome! Log In Create A New Profile

Advanced

prox-pass removes SM_USER Header depending on the client

Posted by toBeLikeMike 
prox-pass removes SM_USER Header depending on the client
January 05, 2017 07:08AM
Dear nginx-Community,

Using the following configuration for a default docker nginx:1.11.3 container :

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;
}
}

I get a strange behaviour on some clients:
A provided SM_USER header disappears.

If I use curl on an ubuntu 16.04 to do a request, I find the following tcp dump listening on the docker network:

GET /resource/InstallationPlace HTTP/1.0
X-Forwarded-Host: devrest.example.com
X-Forwarded-Server: devrest.example.com
X-Forwarded-For: 178.12.225.55
Host: devrest:8080
Connection: close
User-Agent: curl/7.35.0
Accept: application/ld+json
Content-Type: application/ld+json
SM_USER: atnqtjrce0cjfve0fbjbsov2ff

and therefore get a correct answer from the API. The same when I use the RESTClient Add-On in Firefox (no matter which OS).

Am I using a java spring rest client, the SM_USER disappears - the same when using SoapUI in windows.

GET /resource/InstallationPlace/ HTTP/1.0
X-Forwarded-Host: devrest.example.com
X-Forwarded-Server: devrest.example.com
X-Forwarded-For: 178.12.225.55
Host: devrest:8080
Connection: close
Accept-Encoding: gzip,deflate
Encoding: UTF-8
Accept: application/ld+json
Content-Type: application/ld+json
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)

It is there when I use tcp dump to listen before nginx changes the request:

GET /resource/InstallationPlace/ 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

As you can see I use
underscores_in_headers on;
and explicitly set
proxy_pass_request_headers on;
in the configuration.

Is there something else I can do to get the SM_USER header through? Maybe explicitly force this header to be set? If so, how can I do this?

Thank you in advance
Werner
Re: proxy-pass removes SM_USER Header depending on the client
January 11, 2017 10:04AM
Ok, seems, it works now.

I had serveral server configurations using or not using the
underscores_in_headers on;
directive.

I put this directive into the http block and now get the same behaviour from curl and java and soapUI.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 189
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready