9951 explained code solutions for 126 technologies


nginxHow to use geoip module


Warning. This module is deprecated, use geoip2 module instead.

geoip_country /var/geoip.dat;

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

set path to geoip country database file

/var/geoip.dat

path to geoip database file

$geoip_city_country_code

variable with detected country code

"RU"

sample value to check upon

return 403 'no';

return 403 header if request is detected as RU