Cyr*_* N. 3 nginx lets-encrypt
每三个月,我的 Let's Encrypt 证书就会过期,我的客户会获得无效的 https 证书。
所以我最近放置了以下 cron 任务:
@weekly certbot renew --quiet && service nginx reload
Run Code Online (Sandbox Code Playgroud)
据我了解,当certbot renew
成功更新证书时,它会返回成功状态(exit(0)),因此&&
紧随其后,因此重新加载nginx。
是的,但它不起作用。我最近让我的服务器再次显示过期的证书,所以我肯定误解了一些东西,和/或我的 cron 任务不好。
你能告诉我路径吗?:)
更好的方法是使用--renew-hook
可以调用脚本的方法。也是--no-self-upgrade
自动续订的好选择,此选项可防止续订期间的更新,这可能会破坏某些内容
cron记录可以
certbot renew --quiet --no-self-upgrade --renew-hook /path/to/hook.sh
Run Code Online (Sandbox Code Playgroud)
hook.sh
#!/bin/sh
set -e
nginx -t -q && nginx -s reload
exit 0
Run Code Online (Sandbox Code Playgroud)
仅当更新操作发生时才会调用此脚本,而不是每周都会调用
完整的解释位于手册页或文档中