一. 阿里云下载ssl证书 然后上传到指定位置(路径自己定义)

2.打开 Nginx 安装目录下 conf 目录中的 nginx.conf 文件 添加如下代码
server {
listen 443;
server_name wx.fancyblog.club;
ssl on;
root /www/html/wxapp;
index index.html index.htm index.php;
ssl_certificate cert/a.pem;
ssl_certificate_key cert/a.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 /www/html/wxapp;
index index.html index.htm index.php;
if (!-e $request_filename) {
rewrite ^(.*)1 last;
break;
}
}
location ~ .phpdocument_root$fastcgi_script_name;
include fastcgi_params;
}
}
并让http 强制跳转 https
server {
listen 80;
server_name wx.fancyblog.club;
rewrite ^(.*) https://1 permanent;
}
3.保存重启nginx 生效
网友评论