Skip to content

Instantly share code, notes, and snippets.

@rslonik
Created August 27, 2019 20:37
Show Gist options
  • Save rslonik/0542504bcdce13ed9fa704873b2a1d7f to your computer and use it in GitHub Desktop.
Save rslonik/0542504bcdce13ed9fa704873b2a1d7f to your computer and use it in GitHub Desktop.
NGINX GEOIP HEADER

nginx -V Precisa ter o módulo --with-http_geoip_module instalado.

mkdir /etc/nginx/geoip cd /etc/nginx/geoip

Baixar a base GeoIP em CSV e converter pra DAT https://dev.maxmind.com/geoip/geoip2/geolite2/ wget https://geolite.maxmind.com/download/geoip/database/GeoLite2-Country-CSV.zip

Baixar https://github.com/sherpya/geolite2legacy Instalar dependencias

python geolite2legacy.py -i GeoLite2-Country-CSV.zip -f geoname2fips.csv -o GeoIP.dat

add no /etc/nginx/nginx.conf: geoip_country /etc/nginx/geoip/GeoIP.dat;

$geoip_country_code irá mostrar o country code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment