Re: Confused about X-Forwarded-For

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
nginx as:
X-Forwarded-For: whatever.ip.was.therebeforenginx,the.ip.hitting.nginx

and if no X-Forwarded-For is present, then it gets added by nginx as:
X-Forwarded-For: the.ip.hitting.nginx

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.
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ