Nginx removes X-Client-IP header added by loadbalancer

Francis Daly francis at
Sat Dec 8 19:15:12 UTC 2012

On Sat, Dec 08, 2012 at 01:20:12PM -0500, mrtn wrote:

Hi there,

> However, if the request is first routed to Nginx and then to the application
> server using: 
> proxy_pass    ;
> proxy_redirect          off;
> then the 'X-Client-IP' header is missing from the request when it reaches
> Tornado. I guess I might need to explicitly add this header in Nginx as
> well, so it can relay it on. What is the right solution here?

It seems to work for me.

Can you provide an nginx.conf and nginx -V output that shows the problem?

When I use

    server {
        listen 8000;

        location / {
            proxy_redirect off;

and try

curl -i -A "" -H X-Client-IP: http://localhost:8000/

then I can see in tcpdump output going to port 8080:

GET / HTTP/1.0
Connection: close
Accept: */*


This is with nginx/1.2.4.

What's different in your setup?

Francis Daly        francis at

More information about the nginx mailing list