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

nginx将http重定向到https

时间:2016-05-13 09:36:59      阅读:154      评论:0      收藏:0      [点我收藏+]

标签:

1.rewrite

 

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

 

2. nginx状态码 497重定向

 

server {  
    listen       443;  
    listen       80;   
    server_name a.com;   
    ssl                  on;  
    
    ssl_certificate      /etc/nginx/test.pem; 
    ssl_certificate_key  /etc/nginx/test.key;  
       
    error_page 497  https://$host$uri?$args;  
}  

  

3.页面刷新

   

<html>  
<meta http-equiv="refresh" content="0;url=https://a.com/">  
</html>  

 

server {  
    listen  80;  
    server_name a.com;  
      
    location / {  
             
        root /www/;  
    }  
     
    error_page  404 https://a.com/;  
}  

 

nginx将http重定向到https

标签:

原文地址:http://www.cnblogs.com/zjxbetter/p/5485988.html

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