CentOS 7 上 nginx 使用 CerBot 安装 https 访问 SSL 证书配置

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/winteroak/article/details/101562503

安装 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 [email protected] --agree-tos --no-eff-email --webroot -w /home/wwwroot/www.qatools.cn -d www.qatools.cn

说明:

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

-d: 网站域名

  • 多个域名证书生成
./certbot-auto certonly --email [email protected] --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

猜你喜欢

转载自blog.csdn.net/winteroak/article/details/101562503