GoAccess + Nginx

Install

Ubuntu にapt で入れます。

# GoAccess (https://goaccess.io/download)
# Official GoAccess' Debian/Ubuntu Repository install

wget -O - https://deb.goaccess.io/gnugpg.key | gpg --dearmor | tee /usr/share/keyrings/goaccess.gpg > /dev/null
echo "deb [signed-by=/usr/share/keyrings/goaccess.gpg] https://deb.goaccess.io/ $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/goaccess.list
apt update
apt install goaccess

サービス設定

# vi /etc/systemd/system/goaccess.service

[Unit]
Description=Goaccess service.
After=network.target

[Service]
Type=simple
Restart=always
ExecStart=/usr/bin/goaccess /var/log/nginx/access.log -o /home/ip_access/goaccess/index.html -p /home/django/simple_db/goaccess_nginx.conf --real-time-html

[Install]
WantedBy=multi-user.target

ポート7890 を開ける

ufw allow from 192.168.0.0/16 to any port 7890 proto tcp

Nginx 設定

# /etc/nginx/nginx_pre.conf

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

access_log /var/log/nginx/access.log vlog;

ブラウザでアクセス(http://192.168.24.75/goaccess/)