• 使用acme.sh定期自动更新https证书


    关于let's encrypt和acme.sh的简介

    Let’s Encrypt is a free, automated, and open Certificate Authority.

    acme.sh 实现了 acme 协议, 可以从 let‘s encrypt 生成免费的证书.

    安装,使用acme.sh

    • 推荐使用root用户安装
    sudo su root
    
    • 安装命令
    curl  https://get.acme.sh | sh
    
    • 生成ssl证书

    使用webroot方式

    acme.sh  --issue -d blog.lomot.cn  --webroot  /var/www/blog.lomot.cn/
    

    或者可以使用nginx方式,具体还有其他的方法参考acme.sh项目的github

    acme.sh  --issue -d blog.lomot.cn  --nginx
    
    • copy证书
    acme.sh --installcert -d blog.lomot.cn --key-file /etc/nginx/ssl/blog.lomot.cn.key --fullchain-file /etc/nginx/ssl/blog.lomot.cn.cer --reloadcmd "service nginx force-reload"
    
    • 应用证书

    这里只给出nginx的方法:

    例如网址是blog.lomot.cn 在/etc/nginx/nginx.conf
    中添加如下

        server {
            listen 80;
            server_name blog.lomot.cn;
            rewrite ^(.*)$  https://$host$1 permanent;
        }
    
        server {
            listen 443;
            server_name blog.lomot.cn;
            ssl on;
            ssl_certificate  /etc/nginx/ssl/blog.lomot.cn.cer;
            ssl_certificate_key /etc/nginx/ssl/blog.lomot.cn.key;
            ssl_session_timeout 5m;
            ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
            ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
            ssl_prefer_server_ciphers on;
            location / {
                proxy_set_header   X-Real-IP $remote_addr;
                proxy_set_header   Host      $http_host;
                proxy_pass         http://localhost:3000;
                proxy_set_header REMOTE-HOST $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            }
        }
    

    证书自动更新

    目前证书在 60 天以后会自动更新, 你无需任何操作. 今后有可能会缩短这个时间, 不过都是自动的, 你不用关心.

    更新acme.sh

    目前由于 acme 协议和 letsencrypt CA 都在频繁的更新, 因此 acme.sh 也经常更新以保持同步.

    升级 acme.sh 到最新版 :

    acme.sh --upgrade
    如果你不想手动升级, 可以开启自动升级:

    acme.sh --upgrade --auto-upgrade
    之后, acme.sh 就会自动保持更新了.

    你也可以随时关闭自动更新:

    acme.sh --upgrade --auto-upgrade 0

    引用

    具体教程可以参考acme.sh的github
    https://github.com/Neilpang/acme.sh



    作者:lomot
    链接:https://www.jianshu.com/p/8984bed9a784
    来源:简书
    简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。
  • 相关阅读:
    [LintCode] Maximum Subarray Difference
    [HDU 3415] Max Sum of Max-K-sub-sequence
    [LintCode] Count of Smaller Number before itself
    [LeetCode] Invert Binary Tree
    [LintCode] Max Tree
    [LeetCode] Implement Stack using Queues
    [LintCode] Maximum Subarray III
    [LeetCode] Basic Calculator & Basic Calculator II
    [LeetCode] Rectangle Area
    Tensorflow[目录结构]
  • 原文地址:https://www.cnblogs.com/gao88/p/10460305.html
Copyright © 2020-2023  润新知