Welcome! Log In Create A New Profile

Advanced

Re: GeoIP data in access_log Nginx

Maxim Dounin
July 27, 2015 01:02PM
Hello!

On Mon, Jul 27, 2015 at 05:10:22AM -0400, Jugurtha wrote:

> Hello World,
>
> I would like to know if is possible to put GeoIP data (country for exemple)
> in my log access (nginx)
> I enabled the GeoIP module in my nginx (configure) and i would like to use
> the "$geoip_country_name" and "$geoip_city" in my accesslog
> I tried to add the two variables in my log format (main) but without
> success
>
> 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" "$geoip_country_name" "$geoip_city"';

This is expected to work fine.

> Result :
>
> my.domain.fr xxx.xxx.xxx.xxx - - [22/Jul/2015:17:14:21 +0200] "GET
> /test.html HTTP/1.0" 404 564 "-" "Mozilla/5.0 (Windows NT 6.3; WOW64)
> AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.134 Safari/537.36"
> "0.001" "HIT" "-" "-"

Most likely geo information is not available for some reason.
First of all I would recommend to check if appropriate GeoIP
databases are present on your system and loaded into nginx using the
geoip_country (for $geoip_country_name) and geoip_city (for
$geoip_city) configuration directives.

--
Maxim Dounin
http://nginx.org/

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

GeoIP data in access_log Nginx

Jugurtha July 27, 2015 05:10AM

Re: GeoIP data in access_log Nginx

Maxim Dounin July 27, 2015 01:02PM

Re: GeoIP data in access_log Nginx

Jugurtha July 28, 2015 08:42AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 290
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready