Let's Encrypt 免费SSL配置

1.安装支持软件
yum install certbot-nginx

升级pip
pip install --upgrade pip

如果pyOpenSSL版本小于0.14,则要先删除再独立安装最新版本(如果yum库没有最新版本的话,有的话直接从yum安装)
yum erase pyOpenSSL (此命令会同步删除certbot-nginx,不可使用)
rpm -e --nodeps pyOpenSSL

pip install --upgrade pyOpenSSL

2.配置单域名方式
certbot --nginx
根据命令提示一步一步,每次好像只能选择一个域名,虽然提示说可以逗号分多个选择,但实际测试不支持。另外注意结束的提示,有pem证书和密钥文件保存的位置要记录下来,以后有用到,如
/etc/letsencrypt/live/tf.example.com/fullchain.pem
/etc/letsencrypt/live/tf.example.com/privkey.pem

配置完后一定要测试续订命令有没有报错:certbot renew,如果有报错,可以删除一些配置/etc/letsencrypt/renewal/,重试。

2.配置通配符方式
安装DNS插件,目前只有部分DNS服务商提供了这个服务(国内大部分DNS商家都没有)
https://certbot.eff.org/docs/using.html#dns-plugins

certbot-dns-cloudflare
certbot-dns-cloudxns
certbot-dns-digitalocean
certbot-dns-dnsimple
certbot-dns-dnsmadeeasy
certbot-dns-google
certbot-dns-luadns
certbot-dns-nsone
certbot-dns-rfc2136
certbot-dns-route53

DNS插件安装成功后提示命令
certbot -a dns-plugin -i nginx -d "*.example.com" -d example.com --server https://acme-v02.api.letsencrypt.org/directory

3.因Let's Encrpty三个月过期,可以自动续订
certbot renew --dry-run

安装脚本到cron里
certbot renew

例如:
0 0,12 * * * python -c 'import random; import time; time.sleep(random.random() * 3600)' && certbot renew 

参考资料

[1] https://certbot.eff.org/lets-encrypt/centosrhel7-nginx

猜你喜欢

转载自my.oschina.net/swingcoder/blog/1821221
今日推荐