您的位置:首页 > 理论基础 > 计算机网络

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

2015-06-02 22:02 896 查看
业务需要通过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/; }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: