Skip to content

Instantly share code, notes, and snippets.

@facsiaginsa
Last active April 11, 2020 02:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save facsiaginsa/d653487ee9443d59912a1147aa5e5fbe to your computer and use it in GitHub Desktop.
Save facsiaginsa/d653487ee9443d59912a1147aa5e5fbe to your computer and use it in GitHub Desktop.
This is tutorial on how to run Go Access (a Visual Web Log Analyzer) behind an NGINX web server on Ubuntu 18.04.

How to Run Go Access behind Nginx Proxy

This is tutorial on how to run Go Access (a Visual Web Log Analyzer) behind an NGINX web server on Ubuntu 18.04.

Get Sudo Privilege

Make sure you have sudo privilege so there are no permission problem when run these command bellow

sudo su

NGINX Install & Config

Install NGINX

apt-get update
apt-get install nginx

Create a Virtual Host

nano /etc/nginx/site-available/goaccess

copy & Paste this config:

map $http_upgrade $connection_upgrade {
    default upgrade;
    '' close;
}

upstream gwsocket {
    server 127.0.0.1:7890;
}

server {
    listen 8080;

    # replace with your actual domain
    server_name your.domain.com;
    
    # if you chose a different location for the webroot, use it here
    root /var/www/html;
	
    location / {
        try_files $uri =404;
    }

    location /ws {
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
        proxy_pass http://gwsocket;
        proxy_buffering off;
        proxy_read_timeout 7d;
    }
}

note that this is a config for http, if you use https please look nginx guide to use ssl. And don't forget yo change your.domain.com to your actual domain.

Create link

ln -s /etc/nginx/site-available/goaccess /etc/nginx/site-enable/

Reload NGINX

service nginx reload

Go Access Install & Config

Install Go Access

apt-get update
apt-get install goaccess

Uncomment some config

nano /etc/goaccess.conf

from here, it is up to you to config the goaccess, but this is enough if you want to visualize nginx access log. You can uncomment these part:

time-format %H:%M:%S
date-format %d/%b/%Y
log-format COMBINED
daemonize true
real-time-html true
ws-url ws://your.domain.com:8080/ws
keep-db-files true 
load-from-disk true

don't forget to change your.domain.com to your actual domain. exit and save.

Run Go Access

goaccess /var/log/nginx/access.log -a -o /var/www/html/live-report.html

wait a couple of minutes until there is live-report.html in /var/www/html/

Access you HTML Page

Your html should be in http://your.domain.com:8080/live-report.html

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