I am using nginx as a load balancing proxy to pass requests using
proxy_pass to upstream servers running my web app. These requests
may or may not come in with X-Forwarded-For, depending on whether the visitor is using a proxy.
I did some digging and as it turns out:
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
Adds the $remote_add to the X-Forwarded-For automatically.
So in summary, if X-Forwarded-For is present, then it gets rewritten by
and if no X-Forwarded-For is present, then it gets added by nginx as:
This behavior is exactly as needed and solves my inquiry. I will update
the wiki to make it more clear that $proxy_add_x_forwarded_for will
automatically include the IP hitting nginx. Thanks.
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now.