使用 Certbot 申请 TLS 证书

Certbot 可以用于从 Let's Encrypt 自动申请、安装、更新免费的 HTTPS 证书(默认只有3个月有效期,可使用脚本自动续期)。

1、安装 Certbot

Linux:apt install certbot
Mac:brew install certbot

2、使用 Certbot 申请 HTTPS 证书

# 手动配置
certbot certonly --manual -d '*.xxx.com' -d 'xxx.com' --preferred-challenges dns

# 自动配置 + 自动验证 apache
certbot certonly --appche -d '*.xxx.com' -d 'xxx.com' --preferred-challenges dns

3、根据提示,将生成的 TXT recorder 文本保存至阿里云(如下图)、腾讯云、AWS等平台的域名设置页中

4、在 Nginx 上设置对应的证书和 key 的路径(若使用了自动配置 + 自动验证,则可忽略本条)

5、自动续期(未完待续)

posted @ 2025-05-29 15:31  江南烟雨梦  阅读(227)  评论(0)    收藏  举报