A
A
AstonMartin2014-06-23 13:19:15
Nginx
AstonMartin, 2014-06-23 13:19:15

Nginx, how to block countries but not crawlers?

Good day!
Please tell me the correct nginx config for blocking countries and at the same time for skipping search robots (by user-agent). Needed to fight DDoS.
Blocking by country, as far as I understand, will be like this:

geoip_country /usr/share/GeoIP/GeoIP.dat;
map $geoip_country_code $bad_country {
    default 1;
    include geo/good_countries;
}

location / {
       if ($bad_country){
              return 403;
       }
}

And where can I put the second condition about the user-agent pass of search robots?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question