GeoIP data in access_log Nginx

Jugurtha nginx-forum at
Tue Jul 28 12:42:42 UTC 2015

Hello Maxim,

Thanks for the reply, you are the best ;)

I would like to add the GeoIP data into my log access to facilitate
processing in Kibana (ELK stack)
Maybe is not the good way because i know it possible to do this with
LogStash (GeoIP Filter), and this would reduce pressure Nginx (what do you
think ?)

#Conf GEOIP (Load GeoIP Lib)   => Downloaded on maxmind website
geoip_country  /var/lib/GeoIP/GeoIP.dat;
geoip_city     /var/lib/GeoIP/GeoLiteCity.dat;

#My log format
log_format  main
        '$host $remote_addr - $remote_user [$time_local] "$request" '
        '$status $body_bytes_sent "$http_referer" '
        '"$http_user_agent" "$http_x_forwarded_for" "$request_time"
"$upstream_cache_status" "$gzip_ratio" "$geoip_country_code"';

=> it works well with "$geoip_country_code" - - [28/Jul/2015:14:29:38 +0200] "GET /test.jpg
HTTP/1.0" 200 270225 "-" "Wget/1.12 (linux-gnu)" "-" "0.048" "MISS" "-"

Merci, thanks again.
Best regards,

Posted at Nginx Forum:,260566,260586#msg-260586

More information about the nginx mailing list