Let Encrypt自动化部署完整指南:从安装到监控

Let Encrypt简介

Let Encrypt通过ACME协议实现SSL证书的自动化签发和续期,是实现HTTPS零成本部署的最佳方案。本文提供从零部署到持续监控的完整实战指南。

安装certbot

Ubuntu/Debian

使用snap安装最新版:sudo snap install certbot –classic。或使用apt:sudo apt install certbot python3-certbot-nginx。推荐snap方式,版本更新更及时。

CentOS/RHEL

sudo yum install epel-release && sudo yum install certbot python3-certbot-nginx。

证书签发

Nginx自动配置

sudo certbot –nginx -d example.com -d www.example.com。certbot自动修改Nginx配置添加SSL相关指令。推荐加上 –redirect 参数自动配置HTTP→HTTPS重定向。

手动模式

sudo certbot certonly –standalone -d example.com。适合没有Web服务器或需要手动管理配置的场景。注意:standalone模式会临时占用80端口。

DNS验证

sudo certbot certonly –manual –preferred-challenges dns -d *.example.com。用于签发通配符证书。需要手动或通过API添加DNS TXT记录。支持Cloudflare、Route53等DNS API自动验证。

自动续期

certbot安装后默认创建systemd timer或cron job自动续期。验证:sudo certbot renew –dry-run。续期后自动reload Nginx:在/etc/letsencrypt/renewal-hooks/post/目录放置reload脚本。

监控告警

  • 使用certbot certificates命令查看所有证书到期时间
  • 使用Prometheus ssl_exporter监控证书状态
  • 设置告警:证书到期前30天Warning、7天Critical
  • 使用crt.sh监控证书透明度日志,发现未授权签发

常见问题

Rate Limit:每个域名每周最多50张证书。解决:使用staging环境测试,生产环境一次到位。端口问题:80端口被占用导致验证失败。解决:使用webroot或DNS验证方式。

🧧 加入Telegram福利群,免费领1万积分

每分钟发红包 | 6款免费游戏 | 积分兑换真金筹码

立即加入 →
Telegram咨询 在线客服
© 2026 Online Casino 狮子会娱乐城 | www.s86.com