记录-配置文件-将网站协议从 HTTP 升级为 HTTPS (基于 Nginx 配置)
简单记录
一般申请SSL证书的网站都会告诉你怎么配置HTTPS的配置,
下面是我的记录
Nginx配置:
server {
listen 443;
server_name inick.top;
ssl on;
root /home/git/web/my-site;
index index.html;
ssl_certificate /etc/nginx/cert/1963213_inick.top.pem;
ssl_certificate_key /etc/nginx/cert/1963213_inick.top.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
location / {
root /home/git/web/my-site;
index index.html;
}
}
server {
listen 80;
server_name inick.top www.inick.top;
rewrite ^/(.*)$ https://$host$1 permanent;
}
证书文件需要自己去申请.
配置完之后,记得重启 Nginx ,开放服务器 443 端口.
放置两个https的域名尝试:
https://www.inick.top
https://inick.top