GoatCounter
GoatCounter 是一个 Google Analytics 的替代品。GitHub
Nginx 配置
server {
server_name stats.example.com;
location / {
proxy_pass http://127.0.0.1:8081;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Connection "";
proxy_http_version 1.1;
}
}
Systemd 配置
先写一个启动脚本
#!/bin/sh
set -e
cd "$(dirname "$(realpath "$0")")"
exec ./goatcounter serve -listen 127.0.0.1:8081 -tls=http -automigrate
Systemd unit:
# ~/.config/systemd/user/goatcounter.service
[Unit]
Description=GoatCounter
[Service]
WorkingDirectory=/srv/goatcounter
ExecStart=/srv/goatcounter/start.sh
[Install]
WantedBy=default.target
启动
systemctl --user enable --now goatcounter.service
Adblock
在 Adblock 中加入 https://stats.example.com/count.js
以避免自己的访问被记录。