更改

添加1,110字节 、 2021年4月18日 (日) 02:13
建立内容为“GoatCounter 是一个 Google Analytics 的替代品。[https://github.com/zgoat/goatcounter GitHub] == Nginx 配置 == <syntaxhighlight lang=nginx> server {…”的新页面
GoatCounter 是一个 Google Analytics 的替代品。[https://github.com/zgoat/goatcounter GitHub]

== [[Nginx]] 配置 ==

<syntaxhighlight lang=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;
}
}
</syntaxhighlight>

== [[Systemd]] 配置 ==

先写一个启动脚本
<syntaxhighlight lang=bash>
#!/bin/sh
set -e
cd "$(dirname "$(realpath "$0")")"
exec ./goatcounter serve -listen 127.0.0.1:8081 -tls=http -automigrate
</syntaxhighlight>

Systemd unit:
<syntaxhighlight lang=ini>
# ~/.config/systemd/user/goatcounter.service
[Unit]
Description=GoatCounter

[Service]
WorkingDirectory=/srv/goatcounter
ExecStart=/srv/goatcounter/start.sh

[Install]
WantedBy=default.target
</syntaxhighlight>

启动

systemctl --user enable --now goatcounter.service

[[Category:Server]]