Forum: NGINX realip module trouble

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Michał Jaszczyk (Guest)
on 2009-01-26 16:54
(Received via mailing list)
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
This topic is locked and can not be replied to.