GeoIP FirstNonPrivateXForwardedForIP

Keyur nginx-forum at
Thu Jun 12 16:36:48 UTC 2014


My website does country based redirection based on result obtained from
GeoIP against IP.

I am facing a problem where GeoIP does not work as first IP in the
X-Forwarded-For has Private network address. (Say

I know GeoIP on private network would fail but the X-Forwarded-For also has
the public IP along with Private IP.

Eg :, - - [Timezone] ......

In some cases where multiple proxies are involved it would show :,, - - 

I want GeoIP should be done on the first non private ip. I could achieve
this in apache using GeoIP module directive called

How to do this in nginx ?

Kindly suggest


Posted at Nginx Forum:,250823,250823#msg-250823

More information about the nginx mailing list