Forum: NGINX geoip filtering not working

2974d09ac2541e892966b762aad84943?d=identicon&s=25 bignginxfan (Guest)
on 2013-07-13 04:09
(Received via mailing list)
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:
http://forum.nginx.org/read.php?2,240802,240802#msg-240802
2974d09ac2541e892966b762aad84943?d=identicon&s=25 Matt520 (Guest)
on 2013-08-16 12:28
(Received via mailing list)
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.
(http://ip2location.com/developers/nginx)

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,240802,241917#msg-241917
F797ddd7f8bd2f6939890e49ee6dc1dc?d=identicon&s=25 AJ Weber (Guest)
on 2013-08-16 15:15
(Received via mailing list)
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
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.