美文网首页
CentOS 7 上 nginx 使用 CerBot 安装 ht

CentOS 7 上 nginx 使用 CerBot 安装 ht

作者: 牧之时 | 来源:发表于2019-09-27 21:35 被阅读0次
    HTTPS-TLS-SSL.png

    安装 CertBot

    CentOS 上安装依赖包:

    yum install epel-release
    

    安装 CertBot:

    cd /root/
    
    wget https://dl.eff.org/certbot-auto --no-check-certificate
    
    chmod +x ./certbot-auto
    
    ./certbot-auto -n
    

    生成 SSL Cert 证书

    • 单个域名生成 https 证书
    ./certbot-auto certonly --email youemail@qatools.cn --agree-tos --no-eff-email --webroot -w /home/wwwroot/www.qatools.cn -d www.qatools.cn
    

    说明:

    **—webroot -w **:网站运行的主目录

    -d: 网站域名

    • 多个域名证书生成
    ./certbot-auto certonly --email youemail@qatools.cn --agree-tos --no-eff-email --webroot -w /home/wwwroot/www.qatools.cn -d www.qatools.cn -d books.qatools.cn
    

    Nginx SSL 证书配置

    • Nginx config 文件配置 qatools.cn.conf
    server {
            listen       443;
            root /www/web/qatools_cn/public_html;
            ssl                  on;
            ssl_certificate      cert/qatools.cn.pem;
            ssl_certificate_key  cert/qatools.cn.key;
            ssl                  on;
            ssl_prefer_server_ciphers on;
            ssl_session_timeout 10m;
            ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
            ssl_ciphers EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
            server_name qatools.cn www.qatools.cn;
            index index.html;
            error_page  400 /errpage/400.html;
            error_page  403 /errpage/403.html;
            error_page  404 /errpage/404.html;
            error_page  503 /errpage/503.html;
            location ~ \.php$ {
                    proxy_pass http://127.0.0.1:88;
                    include naproxy.conf;
            }
            location ~ /\.ht {
                    deny  all;
            }
            location / {
                    try_files $uri @apache;
            }
            location @apache {
                     internal;
                     proxy_pass http://127.0.0.1:88;
                     include naproxy.conf;
            }
    }
    
    • Nginx 重新启动或重新加载 conf 文件

      重载 conf 文件

    nginx -s reload
    

    重启 ngin x

    service nginx restart
    

    相关文章

      网友评论

          本文标题:CentOS 7 上 nginx 使用 CerBot 安装 ht

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