标签:nginx
业务需要通过https提供服务,输入http自动跳转https.
1.nginx的rewrite方法
将所有的http请求通过rewrite重写到https上即可
server {
listen 80;
server_name qunyingliu.qq.com;
rewrite ^(.*)$ https://$host$1 permanent;
}
2. index.html刷新网页
跳转
index.html
<html> <meta http-equiv="refresh" content="0;url=https://qunyingliu.qq.com/"> </html>
nginx配置
server {
listen 80;
server_name qunyingliu.qq.com;
location / {
#index.html放在虚拟主机监听的根目录下
root /data/web/websites/qunyingliu.qq.com/http;
}
#将404的页面重定向到https的首页
error_page 404 https://qunyingliu.qq.com/;
}
nginx强制使用https访问(http跳转到https)
标签:nginx
原文地址:http://liuqunying.blog.51cto.com/3984207/1657662