I use nginx as a reverse proxy in front of our application web server (gunicorn; it's a Django app). Majority of the users hitting this web application are actually routed through a forward proxy.
Since requests pass through the forward proxy's servers, the IP address in these cases is always from proxy servers instead of from the original requestor. I want to rectify this situation.
All requests originating from the forward proxy contain a header via:proxy
. In such requests, the original requestor IP is sent in a separate HTTP header field called X-IORG-FBS-UIP
(and also X-FORWARDED-FOR
).
My question is, how can I configure nginx such that it detects whether the request has via:proxy
header, and if so, logs the original requestor IP from the X-IORG-FBS-UIP
header? An illustrative example would be great; thanks in advance! My nginx is v 1.4.6
Note that I do not have the IP ranges used by the forward proxy. If I did, one way to solve this problem would been setting up etc/nginx/conf.d/proxies_acl.conf
with:
set_real_ip_from 1.2.3.0/22;
set_real_ip_from 23.22.20.0/22;
real_ip_header X-IORG-FBS-UIP;