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:
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.