1

I've the following problem with Nginx and GeoIP and will be nice if you can give me some pointers about the solution.

Note: I know this can be solved on DNS side, but that won't be possible by now so I'm looking for other solution.

The problem
My www.domain.com has 1.1.1.1 IP address located in Amazon running Nginx with a redirect like this:

location / { proxy_pass http://2.2.2.2 proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } 

On 2.2.2.2 there's another nginx using geoIP. The problem is that all my clients seems to come from 1.1.1.1, as 2nd nginx is geolocating by $remote_addr.

Is there any way to catch real client IP ($remote_addr on 1.1.1.1) and pass it as a different variable to 2.2.2.2 and use it on geolocalization?

Any tip, comment or RTFM is welcome. I'll keep looking for a solution to try to answer this question.

Thanks.

1 Answer 1

2

On your upstream nginx, use the RealIpModule to get the real IP out of the X-Forwarded-For header that you are sending from your downstream nginx.

For example:

server { set_real_ip_from 1.1.1.1; real_ip_header X-Forwarded-For; 
1
  • Hi Michael, thanks for your help. This solved the issue! Commented Aug 8, 2013 at 19:06

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.