码迷,mamicode.com
首页 > Web开发 > 详细

Nginx服务器http重定向到https

时间:2017-11-10 17:02:25      阅读:219      评论:0      收藏:0      [点我收藏+]

标签:nginx http重定向https

Nginx服务器http重定向到https

server {    
          listen       80;    
          server_name  test-ftqc.navinfo.com;    
          rewrite ^(.*)$ https://$server_name$1 permanent;    
         }

或者

server {    
          listen       80;    
          server_name  test-ftqc.navinfo.com;    
          rewrite  ^  https://$server_name$request_uri? permanent;    
         }

 

现在nginx新版本已经换了种写法,上面这些已经不再推荐。

下面是nginx http页面重定向到https页面最新支持的写法:

复制代码  
server {    
    listen      80;    
    server_name    test-ftqc.navinfo.com;    
    return      301 https://$server_name$request_uri;    
}

server {  
    listen      443 ssl;    
    server_name    test-ftqc.navinfo.com;

    [....]  
}

Nginx服务器http重定向到https

标签:nginx http重定向https

原文地址:http://pengjc.blog.51cto.com/9255463/1980673

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!