nginx下配置SSL证书
wordpress环境下 更改nginx配置文件
1 |
vim /usr/local/nginx/conf/vhost/***.conf |
在443端口的服务中添加
1 2 |
ssl_certificate 证书文件路径/证书.pem; ssl_certificate_key 证书文件路径/证书.key; |
然后重启nginx
1 |
/usr/local/nginx/sbin/nginx -s reload |
nginx下Http自动跳转Https
在nginx配置中添加如下代码,把所有的的http请求转发到https请求下
1 2 3 4 5 6 7 |
# 把http请求全部重写到https server { listen 服务器IP:80;//这里IP地址自己替换 listen [::]:80; server_name www.test.com test.com;//这里自己的域名自己替换 rewrite ^(.*)$ https://$host$1 permanent; } |
然后重启ngixn
1 |
/usr/local/nginx/sbin/nginx -s reload |