Linux配置nginx强制使用https访问(http跳转到https)

思路
最容易想到的方法,将所有的http请求通过rewrite重写到https上即可
配置

1
2
3
4
5
6
server {  
listen 80;
server_name bestsmartfoot.top;

rewrite ^(.*)$ https://$host$1 permanent;
}

效果
搭建此虚拟主机完成后,就可以将http://bestsmartfoot.top、bestsmartfoot.top、www.bestsmartfoot.top的请求全部重写到https://www.bestsmartfoot.top/上了

本文结束啦感谢您的阅读

本文标题:Linux配置nginx强制使用https访问(http跳转到https)

文章作者:Smartfoot

原始链接:http://blog.bestsmartfoot.top/2018/09/19/linux-https-rewrite/

许可协议: 署名-非商业性使用-禁止演绎 4.0 国际 转载请保留原文链接及作者。

公众号