2 messages in ru.sysoev.nginxRe: Confused about X-Forwarded-For
FromSent OnAttachments
Rt IbmerApr 26, 2008 9:06 pm 
Rt IbmerApr 28, 2008 6:18 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: Confused about X-Forwarded-ForActions...
From:Rt Ibmer (rtib@public.gmane.org)
Date:Apr 28, 2008 6:18:38 am
List:ru.sysoev.nginx

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.