首先你要有个域名,我这边以在 aliyun 购买的域名为例
前期准备
创建一个Aliyun的AliyunDNSFullAccess权限的子账号,并记录下 AccessKey ID 和 AccessKey Secret
安装 certbot
yum install certbot
安装 certbot aliyun 插件: https://github.com/tengattack/certbot-dns-aliyun
sudo snap install certbot-dns-aliyun
sudo snap set certbot trust-plugin-with-root=ok
sudo snap connect certbot:plugin certbot-dns-aliyun
/snap/bin/certbot plugins
制作证书
首先准备好阿里云的配置文件: /etc/letsencrypt/cert.ini
dns_aliyun_access_key = xxxxx
dns_aliyun_access_key_secret = yyyyy
执行一下命令开始制作证书
certbot certonly -a certbot-dns-aliyun:dns-aliyun \
--certbot-dns-aliyun:dns-aliyun-credentials /etc/letsencrypt/cert.ini \
-d xxx.cn \
-d "*.xxx.cn"
使用证书
在nginx里配置证书使用
listen 443 ssl http2;
server_name x-xi.cn www.x-xi.cn;
ssl_certificate /etc/letsencrypt/live/xxx.cn/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/xxx.cn/privkey.pem;
ssl_session_timeout 5m;
ssl_protocols SSLv3 TLSv1.2;
ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP;
ssl_prefer_server_ciphers on;
ssl_stapling on;
ssl_stapling_verify on;