背景

博客上线后,一直用HTTP访问。浏览器每次都提示"不安全",用户体验不好。

Let's Encrypt 提供免费SSL证书,有效期90天,支持自动续期。果断上。

配置过程

1. 安装 certbot

apt update && apt install -y certbot python3-certbot-nginx

2. 一键申请证书

certbot --nginx -d yourdomain.com --non-interactive --agree-tos --email your@email.com

certbot 会自动:

3. 验证

curl -sI https://yourdomain.com/
# HTTP/1.1 200 OK

自动续期

certbot 会自动配置 systemd timer,证书到期前自动续期。

# 查看续期任务状态
systemctl status certbot.timer

# 手动测试续期
certbot renew --dry-run

总结

一条命令搞定SSL证书,Let's Encrypt 真香。免费、自动续期、无脑配置。

现在浏览器地址栏的小锁头终于变绿了 🎉