我正在尝试自行托管可信分析。到目前为止,我已经安装了 docker,并启动了 docker 容器。我还确保 nginx 正在运行、具有有效配置、通过 ufw 允许端口 80 和 443,并使用域配置了 nginx https://plausible.example.com
:。
我的 nginx 配置如下:
server {
server_name plausible.example.com;
location / {
proxy_pass http://localhost:8000;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
listen [::]:443 ssl; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/plausible.example.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/plausible.example.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = plausible.example.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
server_name plausible.example.com;
listen 80;
listen [::]:80;
return 404; # managed by Certbot
}
问题是当我尝试访问时plausible.example.com
出现502 bad gateway
错误。当我检查 nginx 错误日志时,我收到此错误:
[error] 935230#935230: *579224 recv() failed (104: Unknown error) while reading response header from upstream
我尝试找到此错误的解决方案,但一直没有成功。如能得到任何帮助,我将不胜感激。谢谢。
编辑:我还应该补充一点,在合理的环境变量中,主机名是:https://plausible.example.com