DEV Community

Cover image for nginx-mod-http-geoip
samnang rosady
samnang rosady

Posted on

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;
  }
  ...
}
Enter fullscreen mode Exit fullscreen mode

GitHub Sample Repository 🐳

Enjoy you practice 🌟

Top comments (0)

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

👋 Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay