自动申请ssl证书


安装Snap

官网 https://snapcraft.io/docs/installing-snapd

yum install epel-release

yum install snapd

systemctl enable --now snapd.socket

ln -s /var/lib/snapd/snap /snap
# 安装完后需要重启服务器

安装Certbot

官网 https://certbot.eff.org/

snap install --classic certbot

ln -s /snap/bin/certbot /usr/bin/certbot

生成证书

# 生成nginx可以使用的ssl证书(会扫描nginx配置文件,取到需要的域名)
certbot certonly --nginx
# 或者使用通配符形式(通配符形式只支持手动续约),将xx.com替换成自己的域名
certbot certonly -d "*.xx.com" -d xx.com --manual --preferred-challenges dns-01

# 测试续签证书
certbot renew --dry-run

nginx配置完成后需要加入定时任务每日刷新nginx配置

crontab -e

0 0 * * * nginx -s reload

文章作者: 花舞流觞
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 花舞流觞 !
  目录