代码改变世界

letsencrypt certbot https自动续期配置

  迷途的码农  阅读(677)  评论(0编辑  收藏  举报
环境certos7
nginx
 
来此加密快速开始文档
 
先安装好snap
 
yum install epel-release
yum install snapd
systemctl enable --now snapd.socket
sudo ln -s /var/lib/snapd/snap /snap

 

 
 
再按照如下教程安装certbot自动获取
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot

 

 
上面两步已经安装完 下面开始拉证书
sudo certbot --nginx
sudo certbot certonly --nginx

 

 
证书有效期是3个月 自动任务每3月续期一次
crontab -e
0 0 1 3,6,9,12 * sh /root/renewHttpsCert.sh

 

 
renewHttpsCert.sh内容
sudo certbot renew --force-renewal

 

 

异常情况:

Detail: Fetching http://domain/.well-known/acme-challenge/EueWlS27qFXsigK43xQ6Cb46v339iBZVU3JUgnU4yiE: Error getting validation data

The Certificate Authority failed to download the challenge files from the temporary standalone webserver started by Certbot on port 80. Ensure that the listed domains point to this machine and that it can accept inbound connections from the internet.

如果验证挑战文件失败 则需要手动安装

certbot certonly --manual

 

然后会手动生成一个验证串和一个文件内容
需要在 webroot/.well-known/acme-challenge 文件夹下生成一个文件 把生成的验证内容放入文件 然后验证即可生成证书。然后手动放入nginx配置 中

webroot/.well-known/acme-challenge

相关博文:
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
点击右上角即可分享
微信分享提示