mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2026-04-25 16:55:56 +03:00
[GH-ISSUE #197] docker 版本通过 watchtower 升级到 v2.0.0-beta4 后出现问题 #4538
Labels
No labels
Q/A
bug
casdoor
dependencies
docker
documentation
duplicate
enhancement
help wanted
invalid
lego
platform:openwrt
platform:windows
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/nginx-ui#4538
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @leic4u on GitHub (Nov 22, 2023).
Original GitHub issue: https://github.com/0xJacky/nginx-ui/issues/197
部署是用的 docker-compose.yml ,内容如下:
docker-compose.yml
今天 watchtower 检测到 docker 版本有更新,自动更新了 nginx-ui 到 v2.0.0-beta4。
更新完后配置的站点都打不开了,检查日志如下:
日志详情
其中第一条里面的
abc.xyz.fullchain.cer是之前用 acme.sh 手动申请的证书。部署本项目后 cp 到
/etc/nginx/ssl目录下用了几天时间,在 2023/11/19 过期,我就把这个证书删除了。然后我在站点管理中,把每一个站点配置都点了一下申请证书并且成功了,今天更新之前都是正常运行可以访问的。
站点管理编辑页面
证书列表
此时的现象就是:
上面配置的所有站点,都无法通过域名访问。但可以通过
ip:port访问到 nginx-ui 面板。打开 nginx-ui 的部分页面时会一直加载,加载不出来。
docker restart 也试过,没用。
看起来像是 nginx 没有启动的样子。
不过忘了截图了。
我看到 docker 部署手册上有一句:
When using this container for the first time, ensure that the volume mapped to /etc/nginx is empty.个人猜测是不是 watchtower 更新时,nginx-ui 认为是一次全新安装,而
/etc/nginx这个文件夹下又有东西了,导致了容器出问题。敬请排查,如需要其他信息,请告知我。
感谢开发者。
@leic4u commented on GitHub (Nov 22, 2023):
not nginx-ui's problem
@0xJacky commented on GitHub (Nov 22, 2023):
我看你的 docker-composer.yaml 里用了相对路径做映射,是不是因为 watchtower 执行更新的时候,执行的目录并不在你原来目录,所以出现了这个问题
@leic4u commented on GitHub (Nov 22, 2023):
我也怀疑是 watchtower 的问题,所以自己手动执行了一遍 docker compose up -d ,也还是一样不行。
我马上再把 docker-compose.yml 改成绝对路径试试。
@leic4u commented on GitHub (Nov 22, 2023):
试了,把 docker-compose.yml 修改如下:
然后
docker stop nginx-uidocker rm nginx-uidocker compose up -d还是一样,启用/禁用还是报错,访问站点还是证书过期。
而且其他容器的 compose 文件我也是用的相对路径,watchtower 更新都是 OK 的,我感觉应该不是它的原因。
@0xJacky commented on GitHub (Nov 22, 2023):
我注意到 nginx: [emerg] cannot load certificate "/etc/nginx/ssl/abc.xyz.fullchain.cer": BIO_new_file() failed (SSL: error:80000002:system library::No such file or directory:calling fopen(/etc/nginx/ssl/abc.xyz.fullchain.cer, r) error:10000080:BIO routines::no such file)
请先把相关配置文件禁用,正常启动 Nginx 再试试
@leic4u commented on GitHub (Nov 22, 2023):
得全部禁用😂,之前那个是通配符证书。
又手动点了一遍。。。后面考虑搞个多选操作不?
禁用完了我执行 docker restart nginx-ui ,再来启用时还是报错,好像并没有解决问题。
我尝试了下把配置里面的证书路径删掉,保存,也报错(但实际成功了,刷新页面可以看到没有路径了)。
然后重新申请证书,也申请不了。因为 nginx 没有启动起来。
@leic4u commented on GitHub (Nov 22, 2023):
神了,刚刚操作了下申请证书,证书列表就只剩这一个了。(同一个配置的,我为了避免重复,改了下配置名称)

但是文件夹里是全都在的:

@0xJacky commented on GitHub (Nov 22, 2023):
可以看到错误日志,应该是 location 规则没配好
@0xJacky commented on GitHub (Nov 22, 2023):
这个证书列表就是只记录在 UI 里启动自动证书或者手动添加的证书,不会自动扫描目录
@0xJacky commented on GitHub (Nov 22, 2023):
是这样,因为你需要先启用 www. 的域名的配置文件,才可以使用 HTTP01 签发证书,或者是改用 DNS Challenge 方式,这样可以在域名不启用的状态下签发证书。
@0xJacky commented on GitHub (Nov 22, 2023):
主要是启用和禁用前会使用 nginx -t 检查一次配置文件,如果 nginx 因为什么原因没开起来,就会出现 exit 1,这个需要检查相关日志。
@leic4u commented on GitHub (Nov 22, 2023):
是启用了的,配的两个 server_name ,一个
www.abc.xyz一个abc.xyz@0xJacky commented on GitHub (Nov 22, 2023):
看日志的话是这个问题,建议贴出配置文件看看
@leic4u commented on GitHub (Nov 22, 2023):
在没有重新操作申请证书之前,这个列表能查到所有证书。参见 1 楼的 「证书列表」 处的截图。
@leic4u commented on GitHub (Nov 22, 2023):
@0xJacky commented on GitHub (Nov 22, 2023):
我怀疑是 database.db 错了,代码里没有写执行批量删除
@0xJacky commented on GitHub (Nov 22, 2023):
确定域名都解析对了对吧,我暂时没法定位到问题的原因,可以等后续版本看看JackyOn Nov 23, 2023, at 12:27 AM, leic4u @.***> wrote:
是这样,因为你需要先启用 www. 的域名的配置文件,才可以使用 HTTP01 签发证书,或者是改用 DNS Challenge 方式,这样可以在域名不启用的状态下签发证书。
是启用了的,配的两个 server_name ,一个 www.abc.xyz 一个 abc.xyz
看日志的话是这个问题,建议贴出配置文件看看
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 80;
listen [::]:80;
listen 443 ssl;
listen [::]:443 ssl;
http2 on;
server_name www.abc.xyz abc.xyz;
ssl_certificate /etc/nginx/ssl/www.immi.run_immi.run/fullchain.cer;
ssl_certificate_key /etc/nginx/ssl/www.immi.run_immi.run/private.key;
if ($server_port = 80) {
rewrite ^(/.*)$ https://$host$1 permanent;
}
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
location / {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
client_max_body_size 1000m;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://localhost:8090/;
}
location /.well-known/acme-challenge {
proxy_set_header Host $host;
proxy_set_header X-Real_IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr:$remote_port;
proxy_pass http://127.0.0.1:9180;
}
}
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>
@leic4u commented on GitHub (Nov 22, 2023):
配置我没有改过,是前两天申请证书成功时的相同配置。解析应该是没有问题的。
@leic4u commented on GitHub (Nov 22, 2023):
那我先不动容器,保持现在的状态配合排查问题。反正我服务器上都是些个人服务,停几天也不影响。有需要随时留言。
@leic4u commented on GitHub (Nov 22, 2023):
证书过期,申请证书 location 的问题不用看了。乌龙了。
是我晚上 9 点多用
apt-get upgrade更新并重启 docker 时,自动把我之前停掉的 nginx 容器启起来了,所以 80 和 443 端口被原来那个 nginx 监听了,才出现了能访问站点,但证书过期,和申请证书出现 location 的问题。现在需要排查的只是在更新 v2.0.0-beta4 后,nginx-ui 面板里面的 nginx 没有启动,导致所有配置站点均无法访问的问题。(下午更新 nginx-ui 时,原来那个 nginx 容器是没有启动的)
我现在把原来那个 nginx 镜像、容器都删掉了。再重启 nginx-ui ,跟下午 4 点多的情况是一样的,无法通过域名访问站点。
我把 issue 里面涉及到这个乌龙的日志、问题和描述都删掉了。只需要看更新后为啥没有读取到目录的问题就行。
@leic4u commented on GitHub (Nov 22, 2023):
我感觉核心就是这一行日志:
需要排查下,为啥 nginx-ui 会去读一个我删掉了的证书(在面板里和在 SSH 里我都删了,因为我发现虽然我在面板里删了,但文件还是在 ssl 文件夹下面)
可能搞清楚这个原因,就能解决这个 issue 了。
@leic4u commented on GitHub (Nov 22, 2023):
找到了,是我自己的问题。
因为自己是把
*.abc.xyz解析到这台服务器的,所以导致我访问任意三级域名,都能跳转到 nginx-ui 面板来。因此我在
nginx.conf文件中加了一个server配置,以阻挡通过随机域名访问:应该就是这个配置导致了今天晚上浪费了您那么多时间,因为我删掉它之后,重启容器,nginx 就是正常启动状态了。
但由此引发出另外两个问题,这两个问题我明天单独开 issue。这个 issue 先关闭了。
cat *.conf这个功能。