realip module trouble

Michał Jaszczyk jasiu85 at gmail.com
Mon Jan 26 17:40:06 MSK 2009


Hi guys,

I'm having some trouble using realip module. My case is rather simple,
so I hope you can help me figure it out :).

My Nginx is accessed either directly by clients or via a proxy. In
either case I'd like to see client's IP in the logs. So I used the
realip module and put this into my config file:

set_real_ip_from 10.60.1.120;
real_ip_header X-Forwarded-For;

It works but not in all cases:

- If I access Nginx directly and don't put any X-Forwarded-For header,
I see correct IP in the log file.
- If I access Nginx directly and put a fake X-Forwarded-For header,
Nginx ignores it and puts correct IP in the log file.
- If I access Nginx via proxy and don't put any X-Forwarded-For
header, I see correct IP in the log file - Nginx reads the
X-Forwarded-For header set by my proxy.
- If I access Nginx via proxy and put a fake X-Forwarded-For header,
the IP in the log file is not correct. My proxy simply adds another
header, so there are two X-Forwarded-For headers in the request and
Nginx seems to take the first one, not the last.

I read previous posts about this issue, but I'm using Nginx 0.7.31 and
I can't apply previous solutions.

Regards,

Mike





More information about the nginx mailing list