GeoIP On Nginx

Igor Sysoev igor at sysoev.ru
Mon Nov 23 11:47:07 MSK 2009


On Mon, Nov 23, 2009 at 03:19:08AM -0500, himesh wrote:

> Hi guys,
> 
>  Iam trying to set up geoip functionality on nginx, I believe it works only with Nginx 0.8 not earlier.

geoip module is in 0.7 since 0.7.63.
Also, there is another geo module in all modern versions.

> I was using GeoIP with Apache to allow access to Only US IPs with the following config...
> 
> SetEnvIf GEOIP_COUNTRY_CODE US AllowCountry
> 
> 
> Deny from all
> Allow from env=AllowCountry
> 
> 
> 
> How can i achieve the same on Nginx. 

server {

   if ($geoip_country_code != US) {
       return 403;
   }

   ...

Also, you may see this thread:
http://nginx.org/pipermail/nginx/2009-August/014705.html


-- 
Igor Sysoev
http://sysoev.ru/en/




More information about the nginx mailing list