使用 Let’s Encrypt(推荐用于 AWS EC2)
1. 安装 Certbot(以 Ubuntu 为例)
sudo apt-get update
sudo apt-get install certbot python3-certbot-nginx
2. 获取证书
sudo certbot --nginx -d sub.example.com
3. 自动续期:Let’s Encrypt 证书有效期为 90 天,Certbot 默认配置自动续期。测试续期:
sudo certbot renew --dry-run