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