のレッツ・暗号化設定HTTPS証明書
1、コーデックをダウンロード
$ cd /root
$ wget https://github.com/certbot/certbot/archive/master.zip
$ unzip master.zip
$ cd certbot-master/
# 查看帮助
$ ./certbot-auto --help
2、証明書を生成し、証明書が有効で90日です
# 例子: $ ./certbot-auto certonly --standalone --agree-tos -v -t --email [email protected] -d siot.staginfo.com
# (将邮箱地址和服务器域名替换)
$ ./certbot-auto certonly --standalone --agree-tos -v -t \
--email <email> \
-d <域名>
図3に示すように、生成された証明書パスHTTPS
# 例子: cd /etc/letsencrypt/live/siot.staginfo.com
$ ls /etc/letsencrypt/live/<域名>
# 文件夹下的文件:cert.pem chain.pem fullchain.pem privkey.pem README
4、証明書を再生成します
$ ./certbot-auto renew
5、証明書は自動的に更新されたスクリプト
$ cd /root
$ vi ssl_auto_auth.sh
#/bin/sh
datetime=`date '+%Y-%m-%d %H:%M:%S'`;
echo "[$datetime] [certbot-auto renew]"
# ps: 注意检查certbot-master的路径是否正确
/root/certbot-master/certbot-auto renew --no-self-upgrade
echo "[$datetime] [nginx restart]"
# ps: 注意检查nginx的路径是否正确
/usr/local/nginx/sbin/nginx -s reload
echo "[$datetime] [ok]"
echo "=============end================"
図6に示すように、タイミングタスクを設定する(午前2時に番号1月)
$ crontab -e
# 每月1号凌晨2点执行
# ps: 注意脚本的路径是否一致
0 2 1 * * /root/ssl_auto_auth.sh >>ssl_auto_auth.log 2>&1
# 1分钟运行一次测试
*/1 * * * * /root/ssl_auto_auth.sh >>ssl_auto_auth.log 2>&1