访问时容器没有打印日志,Nginx 有错误日志,怀疑是 Nginx 配置有问题。。
部署方式 Docker compose,链接本地部署的数据库
Docker compose 配置文件如下:
version: "3"
services:
halo:
image: halohub/halo:2.2.1
container_name: halo
restart: on-failure:3
volumes:
- /home/halo/.halo2:/root/.halo2
ports:
- "8081:8081"
command:
- --spring.r2dbc.url=r2dbc:pool:postgresql://172.17.0.1:5432/halo
- --spring.r2dbc.username=halo
# PostgreSQL 的密码,请保证与下方 POSTGRES_PASSWORD 的变量值一致。
- --spring.r2dbc.password=**********
- --spring.sql.init.platform=postgresql
# 外部访问地址,请根据实际需要修改
- --halo.external-url=https://www.zhangtianci.cn/
# 初始化的超级管理员用户名
- --halo.security.initializer.superadminusername=**********
# 初始化的超级管理员密码
- --halo.security.initializer.superadminpassword=**********
Nginx 配置文件如下:
server {
listen 80;
server_name www.zhangtianci.cn;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_tokens off;
keepalive_timeout 5;
server_name www.zhangtianci.cn;
ssl_certificate /etc/nginx/certificate/1_www.zhangtianci.cn_bundle.crt;
ssl_certificate_key /etc/nginx/certificate/2_www.zhangtianci.cn.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
# 上传文件最大值限制
client_max_body_size 1024M;
location / {
proxy_set_header HOST $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:8081;
}
}
Nginx 错误日志如下:
2023/02/15 22:10:55 [error] 622#622: *81 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 120.244.40.116, server: www.zhangtianci.cn, request: "GET /console HTTP/1.1", upstream: "http://127.0.0.1:8081/console", host: "www.zhangtianci.cn"
2023/02/15 22:10:56 [error] 622#622: *81 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 120.244.40.116, server: www.zhangtianci.cn, request: "GET /favicon.ico HTTP/1.1", upstream: "http://127.0.0.1:8081/favicon.ico", host: "www.zhangtianci.cn", referrer: "https://www.zhangtianci.cn/console"