Content-Type header not proxied to downstream hosts

Hi,

I’m new to nginx so am probably making a simple mistake but, for the
life of
me, I can’t see what.

I want to proxy requests with all headers that the request had to a
downstream server if it matches a regex. I also have an issue with the
regex, but let’s leave that for another post.

The nginx conf is very simple. I know the request sent to nginx
contains
the Content-Type header with value application/json from the access log:

Format:

$remote_addr - $remote_user [$time_local] “$request”
$sent_http_content_type
’ '$status $body_bytes_sent “$http_referer” ’ ‘“$http_user_agent”
“$http_x_forwarded_for”’

Output:

127.0.0.1 - - [10/Dec/2014:18:34:49 -0800] “GET
/event/3F0046E6B50F75A8/info
HTTP/1.1” application/json 200 532 “-” “Apache-HttpClient/4.3.5 (java
1.5)”
“-”

However, the downstream host doesn’t receive it. All other headers,
including custom headers, are sent.

My nginx config is basic, see this gist:

https://gist.github.com/mikquinlan/e68848bb4930725a6fdd

I have a workaround by manually adding the header, but I shouldn’t have
to
do it:

proxy_set_header Content-Type application/json;

I get the same result using nginx 1.4.4 and 1.6.2.

nginx -V output is below.

Any ideas what I’m doing wrong?

All help appreciated.

Mik

Output of nginx -V

nginx version: nginx/1.6.2
built by clang 6.0 (clang-600.0.51) (based on LLVM 3.5svn)
TLS SNI support enabled
configure arguments: --prefix=/usr/local/Cellar/nginx/1.6.2
–with-http_ssl_module --with-pcre --with-ipv6
–sbin-path=/usr/local/Cellar/nginx/1.6.2/bin/nginx
–with-cc-opt=‘-I/usr/local/Cellar/pcre/8.35/include
-I/usr/local/Cellar/openssl/1.0.1i/include’
–with-ld-opt=‘-L/usr/local/Cellar/pcre/8.35/lib
-L/usr/local/Cellar/openssl/1.0.1i/lib’
–conf-path=/usr/local/etc/nginx/nginx.conf
–pid-path=/usr/local/var/run/nginx.pid
–lock-path=/usr/local/var/run/nginx.lock
–http-client-body-temp-path=/usr/local/var/run/nginx/client_body_temp
–http-proxy-temp-path=/usr/local/var/run/nginx/proxy_temp
–http-fastcgi-temp-path=/usr/local/var/run/nginx/fastcgi_temp
–http-uwsgi-temp-path=/usr/local/var/run/nginx/uwsgi_temp
–http-scgi-temp-path=/usr/local/var/run/nginx/scgi_temp
–http-log-path=/usr/local/var/log/nginx/access.log
–error-log-path=/usr/local/var/log/nginx/error.log
–with-http_gzip_static_module

Posted at Nginx Forum:

On Wed, Dec 10, 2014 at 09:47:21PM -0500, hyperion wrote:

Hi there,

I want to proxy requests with all headers that the request had to a
downstream server if it matches a regex.

I suspect there may be a terminology confusion here; but from this mail,
I am not sure what problem you are reporting.

The client makes a request of nginx; nginx makes a request of upstream;
upstream sends a response to nginx; nginx sends a response to the
client.

Two requests, two responses.

Which of those four sets of headers are you concerned about?

The nginx conf is very simple. I know the request sent to nginx contains
the Content-Type header with value application/json from the access log:

I don’t see that header value in this access_log.

http://nginx.org/en/docs/http/ngx_http_core_module.html#variables

Good luck with it,

f

Francis D. [email protected]

Hi Francis

Thanks again for your response.

Using the info you provided I was able to debug and fix the issue. It’s
actually an issue in the client library I’m using to make the request to
Nginx.

Mik

Posted at Nginx Forum:

On Thu, Dec 11, 2014 at 12:57:54PM -0500, hyperion wrote:

Hi there,

Thanks again for your response.

Using the info you provided I was able to debug and fix the issue. It’s
actually an issue in the client library I’m using to make the request to
Nginx.

You’re welcome.

It’s good that you found your answer; and thanks for putting the result
on-list so that the next person looking will be able to see the outcome.

Cheers,

f

Francis D. [email protected]