Geoip filtering not working

Hello,

I’m trying to figure out why Nginx’s geoip modules doesn’t seem to
filter
out certain ip’s from a banned country. I manually tested the GeoIP.dat
using ‘geoiplookup’ against a few ips that successfully connected but
were
in a banned country. GeoIP.dat was fine, it wasn’t the problem. Maybe
its a
config problem? Wondering if you guys can help.

i have the following lines in config:

geoip_country /usr/share/GeoIP/GeoIP.dat;

server {

if ($geoip_country_code = CN) {
return 444;
}

}

Please help!

Posted at Nginx Forum:

Hi, I was looking for the zip code from a given IP address few months
back
and now I’ve got the solution from IP2Location. You can try IP2Location
module see if it helps in your issues and good luck.
(IP2Location IP Geolocation Nginx Module | IP2Location)

Posted at Nginx Forum:

I have this working pretty well (ok, I think very_well ) with GeoIP.

I used a MAP in the main nginx.conf like this:
map $geoip_country_code $allowed_country {
default 0;

     US         1;
     GB         1;
     CA         1;
     EU         1;
 }

Then, in my default.conf, the first statement(s) in the relevant
“location’s” is:

if ($allowed_country = 0) {
return 418;
}

Again, this works for me, and you can add “allowed countries” in just
one place: the “map”.

-AJ