Is it possible to make Nginx HttpGeoIPModule use the X_Forwarded IP that is sent via HAProxy? It is currently just using the incorrect server IP, but unsure how I can make Nginx use the X_Forwarded IP.

Any ideas?

link|improve this question

46% accept rate
James, just for clarification, are you seeing the X-Forwarded-For ip address in nginx's access log and the geoip module still uses the proxy's address ? – Ochoto Feb 14 '11 at 23:38
feedback

2 Answers

Have you tried using the RealIPModule and setting the X-Real-IP to X-Forwarded-For

You have to pass --with-http_realip_module during compile time to build the module because it is not built by default.

http://wiki.nginx.org/HttpRealIpModule

link|improve this answer
If you read my question, I am already doing this and I am asking whether I can make HttpGeoIPModule obey this. It does not at the moment. – James Feb 14 '11 at 0:21
feedback

Sameer's answer is correct.

You'll need to configure and compile Nginx with the --with-http_realip_module option.

Then set the following option in the Nginx configuration:

set_real_ip_from 1.2.3.4;

real_ip_header X-Forwarded-For;

Where 1.2.3.4 is the IP Address of HAProxy

In HAProxy you'll need the following options:

option httpclose

option forwardfor

I found this website helpful: http://www.somerorbay.com/vps-and-dedicated/nginx-behind-haproxy-x-forwarded-for-getting-real-client-ip

link|improve this answer
If you read my question, I am already doing this and I am asking whether I can make HttpGeoIPModule obey this. It does not at the moment. – James Feb 14 '11 at 0:21
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.