Country / CIDR banning

Jim Ohlstein jim at ohlste.in
Mon Aug 3 06:58:33 MSD 2009


Shri @ DevLib.Org wrote:
> We've been getting an extraordinary amount of spam from a few IP 
> ranges (hosting proxies) and countries (Nigeria for example) on our 
> classifieds section.
>  
> Mod Geo_IP
> =============
> http {
>     geoip_country  /usr/local/share/max/GeoIP.dat;
> ......
> =============
> and the result would be in $geoip_country_code
>  
> *How would I ban based on this result ... for the whole server?*

server {
        if ($geoip_country_code = NG) {
        return 403;
    }
    ...
}
> * *
>  
> Banning by CIDR
> In Apache a simple Deny from CIDR would work in the Directory / section.
>  
> *How can I do this in Nginx?*
>
> Thanks!
>  
> Shri
>  
Jim





More information about the nginx mailing list