Correct IP in access log

Hello,

I’m in the process of upgrading my setup. We’re installing nginx on a
new server. While we transition (and dns propogates), I will keep the
old nginx server running. I’m going to route requests that hit the
old nginx server to my new nginx server, and then from there to the
new backend webservers.

Now, to keep my stats up to date, I need to capture the correct IP
address in the logs on the new nginx server. On the old nginx server,
I have the following:

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

Looking at the access log on the new server, I see all requests coming
from the same IP - that of the old server. Any thoughts?

Thanks!

On Mon, Sep 29, 2008 at 4:48 PM, Neil S. [email protected] wrote:

Looking at the access log on the new server, I see all requests coming
from the same IP - that of the old server. Any thoughts?

you need to configure the backend nginx to “trust” the header of the
frontend using “set_real_ip_from”

set_real_ip_from 192.168.1.0/24;

etc.

On Mon, Sep 29, 2008 at 5:58 PM, mike [email protected] wrote:

you need to configure the backend nginx to “trust” the header of the
frontend using “set_real_ip_from”

Oops, minor correction. You need to set both of these. Igor has
written a patch for latest 0.7.x (and who knows what other versions
work) to allow -any- header to be used as the “real ip”, otherwise an
unaltered nginx can use either X-Forwarded-For or X-Real-IP.

set_real_ip_from 192.168.1.0/24;
real_ip_header X-Forwarded-For;

You also need to make sure the “realip” module is enabled. Not sure if
it’s own by default.

How can I check what modules are enabled?

nginx -V