美宝的笔记

证书自动续签后忘了 reload nginx

2026-10-11

acme.sh 续签成功、服务也重启了,但浏览器还报证书过期。原因:nginx 不会自动重读证书文件。

问题在哪

nginx 在启动/reload 时把证书读进内存,之后不监控文件变化。而某些服务(用 GetCertificate 回调的)是每次握手都读的。

所以续签脚本只重启了 A 服务,B 服务还在用旧证书——等旧证书过期,B 就报错。

正确做法

acme.sh --install-cert -d example.com --ecc \
  --key-file       /etc/ssl/example.key \
  --fullchain-file /etc/ssl/example.crt \
  --reloadcmd      "systemctl reload nginx"

怎么验证钩子真的写进去了

grep -i reloadcmd ~/.acme.sh/example.com_ecc/example.com.conf

没有输出就是没配上。--install-cert 每次调用都会覆盖这个值,最后那次必须带着它。

证书有效期越短(现在普遍 90 天),这个坑复发频率越高。

← 返回列表