9951 explained code solutions for 126 technologies


nginxHow to use geoip2 module


geoip2 /etc/country.mmdb {
  auto_reload 5m;
  $geoip2_data_country_code country iso_code;
}

server {
  if ( $geoip2_data_country_code = "RU" ) {
    return 403 'no no';
  }
}ctrl + c
geoip2

geoip2 module directives

auto_reload 5m

check for DB updates every 5 minutes

$geoip2_data_country_code

this variable will store detected country code (detailed documentation)

return 403 'no no';

forbidden access if country code is RU

/etc/country.mmdb

maxmind geoip database file