Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We have webserver setup as follows

Loadbalancer (HAPROXY) <---> Nginx <---> App servers

To make Nginx aware of real clients that are making connections , I compiled Nginx with HttpRealIpModule and did the configuration changes. HAPROXY is also configured to forward XFF header. Nginx is getting right at least partially( my observation) if the client is browsing with pubic IP address. In case of clients which has private IP and behind another client side proxy like SQUID, I am getting the private IP of a client rather than the PUBLIC IP from which the private IP is being NATTED. According to Nginx Module documentation[ ], HttpRealIpModule should be getting last ip in the X-Forwarded-For header for replacement. Here's the NGREP dump for a client with private IP behind squid proxy

T -> [AP]
.1315664739.21; __utmb=82961925.3.10.1315664739; __utmc=82961925;|utmccn=        (referral)|utmcmd=referral|utmcct=/users/sign_in; SnapABugHistory=206
#..If-None-Match: "cc1ff315751caad21aea3dfd5392a56a"..Via: 1.1 atmosphere.sprout.lan:3128    (squid/2.7.STABLE9)..X-Forwarded-For: max-age=259200..X-Forwarded-For: 

XFF header here is atmosphere.sprout.lan:3128 (squid/2.7.STABLE9)..X-Forwarded-For: max-age=259200..X-Forwarded-For:

The last ip seen here in the header is yet the log file of nginx shows the client's private ip

is this normal ??

share|improve this question

This can happen due to a number of things. Nginx is in first place a proxy, therefore it will retain HTTP Headers. So if your HAproxy (or even if the user's LAN Proxy) already supplies a X-Forwarded-For, you have a pretty good chance it will be retained through all proxies (HAproxy -> nginx -> backend).

please +1 if it helped :) thanks

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.