Quick HTTP Statistics with Nginx and GoAccess

I was looking for a quick way to do some statistical analysis on the log files I have. The HTTP server I’m using is Nginx. By default the logs were not in the format I wanted so what I’ll do here is document the adventure through the configs and then onto the log processing through GoAccess.

To get Nginx logging in the format I wanted I edited the global conf file located at the path ‘/etc/nginx/nginx.conf’ and added this to it in the logging section. As time goes on I may change the format but this one is an easy to use common format.

log_format '$remote_addr - $remote_user [$time_local] '
    '"$request" $status $body_bytes_sent '
    '"$http_referer" "$http_user_agent"';

Then in each individual site config I changed the access_log setting. By default all the logs were abridged and combined for all sites. Having them separated into separate files by site is useful for me

access_log /var/log/nginx/tonycrowe.com.log combined;

I gave Nginx a restart so it will start using the new format and wait a while. I came back later and installed GoAccess which took a few seconds because the package was available on my distro(Debian).

apt-get install goaccess -y

Display log via terminal view:

goaccess -f /var/log/nginx/tonycrowe.com.log

Output to HTML:

goaccess -f /var/log/nginx/tonycrowe.com.log > tc-stats.html


Author Tony Crowe, Salt Lake City, UT
Lato font by Łukasz Dziedzicwww.latofonts.com/team
Roboto font by Christian Robertson, Google Incchristianrobertson.comwww.google.com/fonts
Inconsolata font by Raph Levien, Google Incwww.levien.comwww.google.com/fonts
hexo: fast, simple & powerful blog frameworkhexo.io
ace editorace.c9.io
Black Granite Water Droplets, William Warbyhttps://www.flickr.com/photos/wwarby