免费通配符证书申请流程

系统:Centos7.6

域名:www.tan1234.com

1、获取certbot-auto并给予执行权限

wget https://dl.eff.org/certbot-auto
chmod u+x certbot-auto

2、开始申请证书

./certbot-auto --server https://acme-v02.api.letsencrypt.org/directory -d "*.tan1234.com" --manual --preferred-challenges dns-01 certonly

//中间的域名换成自己的

这里是填邮箱,可以随便写,接受安全提醒和续期提醒的。

到下面这步就停下

到自己的域名解析去添加个文件解析,我的是阿里云的

再另外开一个远程窗口执行dig _acme-challenge.tan1234.com txt

出现上述提示的txt解析即可

再回来继续回车执行下一步,出现下述提示则说明配置成功

配置证书存放在/etc/letsencrypt/live/tan1234.com/里了

3.配置nginx支持ssl及http自动跳转https

server {

server_name www.tan1234.com;

charset utf-8;

listen 443 ssl;

ssl_certificate /etc/letsencrypt/live/tan1234.com/fullchain.pem;

ssl_certificate_key /etc/letsencrypt/live/tan1234.com/privkey.pem;

location / {

root html;

index index.html index.htm;

}

}

server {

listen 80;

server_name www.tan1234.com;

charset utf-8;

rewrite ^(.*)$ https://$server_name$1 permanent;

#指定PEM格式的证书文件   

ssl_certificate      

#指定PEM格式的私钥文件  

ssl_certificate_key  

重启下nginx即可http自动跳转https,在 /etc/letsencrypt/renewal 目录下,有网站的 renewal 的配置文件

vim /etc/letsencrypt/renewal/tan1234.com.conf

证书可以使用3个月,提前30天续期。

接下来只需要在阿里云添加上解析,该域名下的所有三级域都会自动跳转https了,共用这个证书。

4.更新证书

// 更新即将到期的证书

./certbot-auto renew

// 强制更新一个证书(这个证书也许还有很久才到期)

./certbot-auto renew --force-renewal

将更新命令加入定时任务,让它自动更新。

发布了60 篇原创文章 · 获赞 9 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/qq_44697035/article/details/102934557