acme.sh 自动更新证书

以前的免费证书有一年的有效期,可以去云服务商的平台弄一些免费的,然后去换上,现在换成3个月了,手动去换太频繁,太麻烦了,所以找了acme.sh

  1. 安装
# 邮箱换成自己的
wget -O - https://get.acme.sh | sh -s email=my@example.com

如果国内安装视频多安装几遍,还不行 https://github.com/acmesh-official/acme.sh/wiki/Install-in-China

2. 申请证书

/root/.acme.sh/acme.sh --issue -d tools.kuaizhuanqian.club   --webroot /app/www/tools.kuaizhuangqian.club   --debug 2  --nginx --force

3. 配置证书,我这里是nginx

ssl_certificate  /root/.acme.sh/tools.kuaizhuanqian.club_ecc/fullchain.cer;
ssl_certificate_key /root/.acme.sh/tools.kuaizhuanqian.club_ecc/tools.kuaizhuanqian.club.key;

4. 配置定时脚本,证书有效期还剩30天会自动续签

# 每月 1 日和 15 日 0 点执行续期
0 0 1,15 * * /root/.acme.sh/acme.sh --cron --home "/root/.acme.sh" --reloadcmd "/app/nginx/sbin/nginx -s reload" >> /var/log/acme-renew.log 2>&1

注意事项

  • 可以管理多个证书,只需要重复第二步和第三步,第四步是共用的。
  • 采用的http验证方式,如果发现第二步卡在了”Processing, The CA is processing your order, please just wait. (21/30)” 验证这一步,检查下第二步配置的 webroot 下有没 .well-known/acme-challenge/ 文件夹,检测下面的文件是否可以访问。单服务器适用
curl -Iv http://tools.kuaizhuanqian.club/.well-known/acme-challenge/MMJUmuMYQO5aGJ5DwRztJBBK_hcEwBA4yukRp4UCh3w
  • 终极方案,把错误信息粘贴到大模型里面,他会帮你排查

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注