-
Notifications
You must be signed in to change notification settings - Fork 9
Setting up Goaccess
Kıvanç Yazan edited this page Aug 29, 2021
·
13 revisions
-
Install goaccess
apt install goaccess
-
Create basic authentication file. Replace
$USER
with username. Second command will ask you to type password in.sudo sh -c "echo -n '$USER:' >> /var/www/html/goaccess/.htpasswd" sudo sh -c "openssl passwd -apr1 >> /var/www/html/goaccess/.htpasswd"
-
Add this to
/etc/nginx/sites-available/default
:location ^~ /goaccess/ { try_files $uri $uri/ =404; auth_basic "Restricted area."; auth_basic_user_file /var/www/html/goaccess/.htpasswd; }
-
Restart nginx with
systemctl reload nginx
-
Add following to
/etc/goaccess.conf
, or alternatively uncomment lines 13, 36 and 64.time-format %H:%M:%S date-format %d/%b/%Y log-format %h %^[%d:%t %^] "%r" %s %b "%R" "%u"
-
Add following root crontab with
sudo crontab -e
.0 * * * * /usr/bin/zcat -f /var/log/nginx/access.log* > /tmp/goaccess-tmp && /usr/bin/goaccess --log-format=COMBINED /tmp/goaccess-tmp > /var/www/html/goaccess/index.html && rm /tmp/goaccess-tmp
-
Optional: Rotate nginx logs more than default of 14:
perl -p -i -e "s/rotate 14/rotate 30/" /etc/logrotate.d/nginx