Logo

dev-resources.site

for different kinds of informations.

nginx-mod-http-geoip

Published at
1/15/2025
Categories
nginx
infrastructure
Author
samnang rosady
Categories
2 categories in total
nginx
open
infrastructure
open
nginx-mod-http-geoip

nginx-mod-http-geoip

nginx-mod-http-geoip is an nginx module that allows you to determine the geographical location of an IP address. The geo of country is presented by Alpha-2 code.

You can find ISO ISO’s full, searchable list of all country codes to find your code.

map $geoip_country_code $allowed_country {
  default no;
  RU yes; # <ISO 3166-1 alpha-2> <yes/no>
}

server {
  ...
  if ($allowed_country = no) {
    return 403;
  }
  ...
}

GitHub Sample Repository 🐳

Enjoy you practice 🌟

Featured ones: