Nginx服务器安装SSL证书

2019-04-28  本文已影响0人  Medicine_8d60

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

image

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 ^(.*)/index.php?s=1 last;

break;

}
}

location ~ .php{ root /www/html/wxapp; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAMEdocument_root$fastcgi_script_name;
include fastcgi_params;
}

}

并让http 强制跳转 https

server {
listen 80;
server_name wx.fancyblog.club;
rewrite ^(.*) https://server_name1 permanent;

}

3.保存重启nginx 生效

上一篇 下一篇

猜你喜欢

热点阅读