子域名统配证书申请

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_32497361/article/details/79779129

申请

  • 下载certbot-auto
    • wget https://dl.eff.org/certbot-auto
  • 赋予可执行的权限
    • chmod +x certbot-auto
  • 申请证书
    • ./certbot-auto certonly -d *.onew.me --manual --preferred-challenges dns --server https://acme-v02.api.letsencrypt.org/directory
    • tip: -d 参数后面更上域名 这里我们加上通配符,这里我们采用的验证方式是dns验证方式.
  • 接下来跟着提示往下走就可以了,最后一步记住证书的位置就可以了.

配置nginx

有了证书我们需要配置一下nginx,才能使证书生效.


server {
                server_name onew.me;
              location / {
                        root /root/web/public;
                        index index.html;
                    }
            listen 443 ssl; # managed by Certbot
            ssl_certificate /etc/letsencrypt/live/onew.me-0001/fullchain.pem;
            ssl_certificate_key /etc/letsencrypt/live/onew.me-0001/privkey.pem;
            ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; 
            include /etc/letsencrypt/options-ssl-nginx.conf;        
     }

重启nginx 就行了

刷新证书

Let’s Encrypt 的证书是会过期的,一般是3个月,到期了我们就要重新申请,这里我们写个定时任务来重新申请就好了.

  • 添加定时任务 crontab -e
  • 添加执行脚本 * * * */3 * root /root/certbot-auto renew --quiet

猜你喜欢

转载自blog.csdn.net/qq_32497361/article/details/79779129
今日推荐