mitchellkrogza / nginx-ultimate-bad-bot-blocker

Nginx Block Bad Bots, Spam Referrer Blocker, Vulnerability Scanners, User-Agents, Malware, Adware, Ransomware, Malicious Sites, with anti-DDOS, Wordpress Theme Detector Blocking and Fail2Ban Jail for Repeat Offenders
Other
3.97k stars 477 forks source link

GeoIP blocking but allowing Googlebot #330

Open mrszop opened 4 years ago

mrszop commented 4 years ago

Hello :),

first of all thank you for this great project! It is really helpful for me!

I've got a question regarding blocking specific countries via GeoIP databases but allowing specific bot to crawl my site. There is this project at https://www.miyuru.lk/geoiplegacy which is offering 'GeoIP Legacy Databases (DAT)' for NGINX (non plus), based on the www.maxmind.com database. My idea is to block all countries but a few specific one like France, Poland, Italy and Germany and also allow to let Googlebot (USA) only (maybe a second bot too) to crawl my site.

geoip_country /usr/share/geoip/GeoIP.dat;
 map $geoip_country_code $allow_country {
 default no;
 IT yes;
 FR yes;
 DE yes;
 PL yes;
}

The problem I'm facing is, that I'm not able to combine two maps like $allow_country and $bad_bot i.e.:

if ($allow_country = no) OR ($allow_country = yes) AND ($bad_bot = 0) {
  allow something;
} else {
  block and return 503;
}

Is there any chance to do this with the nginx-ultimate-bad-bot-blocker?

Cheers, Szop