美文网首页
使用Let's Encrypt

使用Let's Encrypt

作者: 9995857 | 来源:发表于2017-05-18 14:34 被阅读0次

    使用Let's Encrypt 创建免费证书

    1. 创建一个专门放证书的文件夹
      mkdir acme
      cd acme

    2. 下载letsencrypt 并制作
      git clone https://github.com/letsencrypt/letsencrypt
      cd letsencrypt
      ./letsencrypt-auto certonly --email xxxxx@126.com

    域名可以填写多个:
    Please enter in your domain name(s)
    xxx.com www.xxx.com

    选择 Place files in webroot directory (webroot)
    并填写 /usr/share/nginx/html/

    1. 查看证书
      cd /etc/letsencrypt/live
      找到自己的域名

    cert.pem 服务器证书
    privkey.pem 是证书私钥

    1. 修改配置文件
    server {
           listen 443;
           listen 80;#用户习惯用http访问,加上80,后面通过497状态码让它自动跳到443端口    
           server_name  www.xxx.com;
    
           ssl on;
           #前面生成的证书,改一下里面的域名就行,不建议更换路径
           ssl_certificate //etc/letsencrypt/live/www.xxx.com/fullchain.pem;
           #前面生成的密钥,改一下里面的域名就行,不建议更换路径 
           ssl_certificate_key /etc/letsencrypt/live/www.xxx.com/privkey.pem;
    
           location / {
                #try_files $uri $uri/ /index.php$is_args$args;
                index  index.php index.html index.htm;
            }
    
            #让http请求重定向到https请求     
            error_page 497  https://$host$uri?$args;   
    }
    
    1. 制作定时任务
      将 命令添加到 crontab 中
      vi /etc/crontab

    0 0 1 * * root sh /etc/nginx/acme/letsencrypt/letsencrypt-auto renew && nginx -s reload >/dev/null 2>&1

    启动定时任务
    service crond start

    相关文章

      网友评论

          本文标题:使用Let's Encrypt

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