如何把网站升级到Https协议下

作为一个技术发烧友,阿文怎么能容忍自己的网站不是https的呢?今天就来整一下。

环境

腾讯云服务器,Centos 7系统。

申请证书

控制台很方便能申请,证书要和域名绑定。

证书拿到后下载下来,目录结构长这样。

[root@VM-24-12-centos wordpress443]# tree cert
cert
|-- Apache
|   |-- 1_root_bundle.crt
|   |-- 2_www.ruanwenwu.com.cn.crt
|   `-- 3_www.ruanwenwu.com.cn.key
|-- IIS
|   |-- keystorePass.txt
|   `-- www.ruanwenwu.com.cn.pfx
|-- Nginx
|   |-- 1_www.ruanwenwu.com.cn_bundle.crt
|   `-- 2_www.ruanwenwu.com.cn.key
|-- Tomcat
|   |-- keystorePass.txt
|   `-- www.ruanwenwu.com.cn.jks
|-- www.ruanwenwu.com.cn.csr
|-- www.ruanwenwu.com.cn.key
`-- www.ruanwenwu.com.cn.pem

我们用到的只有www.ruanwenwu.com.cn.key和Nginx目录下的1_www.ruanwenwu.com.cn_bundle.crt。

配置nginx服务

https

server {
    listen       443 ssl;
    server_name  www.ruanwenwu.com.cn;
    ssl_certificate conf.d/cert/Nginx/1_www.ruanwenwu.com.cn_bundle.crt;
     #请填写私钥文件的相对路径或绝对路径
     ssl_certificate_key conf.d/cert/www.ruanwenwu.com.cn.key; 
     ssl_session_timeout 5m;
     #请按照以下协议配置
     ssl_protocols TLSv1.2 TLSv1.3; 
     #请按照以下套件配置,配置加密套件,写法遵循 openssl 标准。
     ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE; 
     ssl_prefer_server_ciphers on;

        location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm index.php;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    location ~ .php$ {
        fastcgi_pass   php:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  /www/wordpress/$fastcgi_script_name;
        include        fastcgi_params;
    }
        location ~ ^/(images|img|javascript|js|css|vue|flash|media|static)/ {
                    autoindex on;
                    access_log  off;
                    expires     30d;
        }
}

http服务

server {
    listen       80;
    server_name  ruanwenwu.com.cn;
    return 301 https://$host$request_uri;
}

http访问做301到htts。到此就大功告成了。

发布于

展开阅读全文

页面更新:2024-03-20

标签:发烧友   协议   腾讯   大功告成   控制台   写法   套件   绑定   路径   证书   网站

1 2 3 4 5

上滑加载更多 ↓
推荐阅读:
友情链接:
更多:

本站资料均由网友自行发布提供,仅用于学习交流。如有版权问题,请与我联系,QQ:4156828  

© CopyRight 2020-2024 All Rights Reserved. Powered By 71396.com 闽ICP备11008920号-4
闽公网安备35020302034903号

Top