dnspod快速获取lets-encrypt 证书脚本

原文:https://github.com/xdtianyu/scripts/tree/master/le-dns

dnspod

下载

wget https://github.com/xdtianyu/scripts/raw/master/le-dns/le-dnspod.sh
wget https://github.com/xdtianyu/scripts/raw/master/le-dns/dnspod.conf
chmod +x le-dnspod.sh

配置

dnspod.conf 文件内容

TOKEN="YOUR_TOKEN_ID,YOUR_API_TOKEN"
RECORD_LINE="默认"
DOMAIN="example.com"
CERT_DOMAINS="example.com www.example.com im.example.com"
#ECC=TRUE

修改其中的 TOKEN 为您的 dnspod api token ,注意格式为123456,556cxxxx。 修改 DOMAIN 为你的根域名,修改 CERT_DOMAINS 为您要签的域名列表,需要 ECC 证书时请取消 #ECC=TRUE 的注释。

运行

./le-dnspod.sh dnspod.conf

最后生成的文件在当前目录的 certs 目录下

cron 定时任务

如果证书过期时间不少于30天, letsencrypt.sh 脚本会自动忽略更新,所以至少需要29天运行一次更新。

每隔20天(每个月的5号和25号)自动更新一次证书,可以在 le-dnspod.sh 脚本最后加入 service nginx reload等重新加载服务。

0 0 5/20 * * /etc/nginx/le-dnspod.sh /etc/nginx/le-dnspod.conf >> /var/log/le-dnspod.log 2>&1

注意 ubuntu 16.04 不能定义 day of month 含有开始天数的 step values,可以替换命令中的 5/20 为 5,25。

更详细的 crontab 参数请参考 crontab.guru 进行自定义

Nginx配置

server {
        listen       443;
        server_name   example.com;
        index index.html index.htm index.php;
        root /apps/example.com;
        ssl on;
        # https证书公钥
        ssl_certificate   /path/certs/example.com/fullchain.pem;
        # https证书私钥
        ssl_certificate_key  /path/certs/example.com/privkey.pem;
        #使用 openssl dhparam -out dh4096.pem 4096 生成
        ssl_dhparam  /path/certs/example.com/dh4096.pem;
        ssl_session_timeout 5m;
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_prefer_server_ciphers on;

        location /{

                try_files $uri $uri/ /index.php?$query_string;
        }

        location ~ ^(.+\.php)(.*)$ {
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index index.php;
                include  fastcgi.conf;
        }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值