使用Let's Encrypt 申请免费通配符 SSL 证书

因为微信小程序的关系,需要使用https。找了找发现了可以使用Let's Encrypt生成通配符 SSL 证书。

# 下载 Certbot 客户端
$ wget https://dl.eff.org/certbot-auto
# 设为可执行权限
$ chmod a+x certbot-auto
# 换成你自己的域名
./certbot-auto certonly  -d "*.zhaobo1.cn" --manual --preferred-challenges dns-01  --server https://acme-v02.api.letsencrypt.org/directory

第三步你可能会因为系统python的版本原因,或者未安装python-pip。报依赖的问题。自己正确安装解决即可。正确安装后会出现下图

11096212-ae11a462a61fdb9a.jpg

示例图

nginx配置文件

        #同时监听80和443端口
        listen 443;
        listen 80;
        #开启ssl
        ssl on;
        ssl_certificate /etc/letsencrypt/live/zhaobo1.cn/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/zhaobo1.cn/privkey.pem;
        ssl_trusted_certificate  /etc/letsencrypt/live/zhaobo1.cn/chain.pem;
        #http跳转https
        if ($server_port = 80 ) {
                return 301 https://$host$request_uri;
        }

这样就完成了https的配置。最以后就是Let's Encrypt免费证书的有效时间只有90天。需要定期自动更新,可以使用crontab定时任务来操作。

0 0 1 */2 * sh /root/https/certbot-auto renew
发布了51 篇原创文章 · 获赞 2 · 访问量 6042

猜你喜欢

转载自blog.csdn.net/weixin_44600422/article/details/89345670