1_cloud.tencent.com_bundle.crt : 证书文件
2_cloud.tencent.com.key :私钥文件
cloud.tencent.com.csr :CSR 文件内容
检查SSL环境:
如果安装nginx时没有编译好ssl模块,则需要重新编译ssl
进入nginx加压目录:
[root@localhost ~]# cd /software/nginx-1.17.0
[root@localhost nginx-1.17.0]# ./configure —prefix=/usr/local/nginx —with-http_stub_status_module —with-http_ssl_module
注意:此步骤后切记不可执行make
会在/software/nginx-1.17.0当前目录下会生产一个名为nginx的文件
拿/software/nginx-1.17.0目录下的nginx文件替换/usr/local/sbin/下的nginx
[root@localhost nginx-1.17.0]# mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bak
[root@localhost nginx-1.17.0]# rm -rf /usr/local/nginx/sbin/nginx
[root@localhost nginx-1.17.0]# cp /software/nginx-1.17.0/nginx /usr/local/nginx/sbin/
查看ssl模块是否编译成功:
[root@localhost sbin]# ./nginx -V
配置SSL:
将1_cloud.tencent.com_bundle.crt 和 2_cloud.tencent.com.key 文件上传至/usr/local/nginx/conf 下;
编辑nginx.conf 配置文件内容:
[root@localhost ~]# vim /usr/local/nginx/conf/nginx.conf
server {# SSL 访问端口号为 443listen 443 ssl;# 填写绑定证书的域名server_name www.dangshen.top; //这里填写证书域名ssl on; #开启ssl# 证书文件名称ssl_certificate 1_cloud.tencent.com_bundle.crt; //这里填写刚刚复制过来的证书文件名称# 私钥文件名称ssl_certificate_key 2_cloud.tencent.com.key; //这里填写刚刚复制过来的私钥文件名称ssl_session_timeout 5m;# 请按照以下协议配置ssl_protocols TLSv1 TLSv1.1 TLSv1.2;# 请按照以下套件配置,配置加密套件,写法遵循 openssl 标准。ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;ssl_prefer_server_ciphers on;location / {# 网站主页路径。此路径仅供参考,具体请您按照实际目录操作。# 例如,您的网站运行目录在/etc/www下,则填写/etc/www。root html;index index.html index.htm;}}server {listen 80; # 监听80端口server_name www.dangshen.top;#将请求转成httpsrewrite ^(.*)$ https://$host$1 permanent;}
检查配置文件:<br />[root@localhost ~]# cd /usr/local/nginx/sbin/<br />[root@localhost sbin]# ./nginx -t
重启Nginx,访问网站验证
[root@localhost sbin]# ./nginx -s reload
