美文网首页
网站设置免费letsencrypt HTTPS 证书以及配置ng

网站设置免费letsencrypt HTTPS 证书以及配置ng

作者: 一件小毛衣 | 来源:发表于2020-01-16 15:04 被阅读0次

    给网站安装免费letsencrypt HTTPS 证书,配置nginx的https
    letsencrypt 提供免费证书,有效期为90天。
    过期后可以重新生成,相当于可以一直免费
    letsencrypt网站
    下面通过certbot 生成证书

    1.下载certbot,并解压

    wget https://codeload.github.com/certbot/certbot/zip/master
    

    2.生成证书

    ./certbot-auto certonly --standalone --agree-tos -d example.com -d www.example.com
    

    错误:
    Problem binding to port 80: Could not bind to IPv4 or IPv6.
    关闭服务器(nginx)之后再执行,即可解决
    3.更新已过期证书

    certbot renew --dry-run
    ./certbot-auto renew
    

    注:(更新时问题)
    Upgrading certbot-auto 0.40.1 to 1.2.0...
    Couldn't download https://raw.githubusercontent.com/certbot/certbot/v1.2.0/letsencrypt-auto-source/letsencrypt-auto. <urlopen error [Errno 111] Connection refused>
    可将其锁定到特定版本并且不接收自动更新,只需在命令后加 --no-self-upgrade 即可。即

    ./certbot-auto renew --no-self-upgrade
    

    4.修改nginx配置

    server {
    ......
    listen  443 ssl;
    ssl_certificate      /etc/letsencrypt/live/xxxxxx.com/fullchain.pem;
    ssl_certificate_key  /etc/letsencrypt/live/xxxxxx.com/privkey.pem;
    ......
    }
    server {
            listen  80;
            server_name xxxxxx.com;
            return 301 https://$host$request_uri;
    }
    

    相关文章

      网友评论

          本文标题:网站设置免费letsencrypt HTTPS 证书以及配置ng

          本文链接:https://www.haomeiwen.com/subject/zgmvbftx.html