首页 > Web开发 > 详细

Nginx服务器http重定向到https

时间:2017-11-10 16:47:36      阅读:263      评论:0      收藏:0      [点我收藏+]

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

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!