nginx的rewrite方法
思路
这应该是大家最容易想到的方法,将所有的http请求通过rewrite重写到https上即可
配置nginx
[root@VM_0_2_centos nginx]# vim /etc/nginx/nginx.conf
修改配置如下:
server {
listen 192.168.1.111:80;
server_name test.com;
#重写http请求
rewrite ^(.*)$ https://$host$1 permanent;
}
检查配置是否正确(出现successful则代表配置无误):
[root@VM_0_2_centos nginx]# nginx -t
重启nginx:
[root@VM_0_2_centos nginx]# serive nginx restart
本文由 giao创作, 采用 知识共享署名4.0 国际许可协议进行许可 本站文章除注明转载/出处外,均为本站原创或翻译,转载前请务必署名 原文地址:《nginx强制使用https访问(http跳转到https)》
最后一次更新于2018-12-24
0 条评论