Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

I have a nginx reverse-proxy (server A) running in front of another nginx server (B).

However, A doesn't seem to pass the IPs correctly to server B.

Even though I have

    proxy_set_header   X-Real-IP  $remote_addr;
    proxy_set_header   Host $host;
    proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;

these lines in my config.

I know for Apache you simply load the RPAF-module.

Is there something similar for nginx ?


share|improve this question
up vote 0 down vote accepted

There is a nice overview of modules here: Specifically you need this:

share|improve this answer
Cheers, this fixed the issue for both logs and PHP. – Tuinslak Mar 24 '11 at 9:26

Some more detail would be helpful on what you mean by "doesn't pass the IPs" - where you're seeing the wrong IP, and what you're expecting.

I'm going to go out on a limb and say that you're probably seeing the reverse proxy's address instead of the client's address in the logs - you can alter your log format to show the contents of the X-Forwarded-For header (the example below is a tweak to the default combined format):

log_format proxied_combined '$http_x_forwarded_for - $remote_user [$time_local]  '
                            '"$request" $status $body_bytes_sent '
                            '"$http_referer" "$http_user_agent"';
access_log logdir/access.log proxied_combined;
share|improve this answer
Yes, indeed, both logs as PHP ($_SERVER['REMOTE_ADDR'] for example) give the proxy's address. – Tuinslak Mar 24 '11 at 7:50

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.