网站制作学习网经验与学习→正文:nginx http跳转https
字体:

nginx http跳转https

经验与学习 2015/3/11 0:03:35  点击:不统计

转www.载for网站制作学习asp必.cn究
 在某些需求中nginx要实现从http跳转到https,很简单在对应的80端口配置文件server中写个rewrite

server{
return 301 https://$host$request_uri;
}
在443端口配置不做任何操作nginx实现http到https跳转
如果是单个文件夹
location /Foraspdir{
return 301 https://$host$request_uri;
}
如果是不同的客户端nginx实现http到https跳转
if ($http_user_agent ~* '(mobile|Mobile|android)') {
 return 301 https://$host$request_uri;
}
 
以上就是nginx实现http到https的跳转。

原载于:本文原载于www.forasp.cn

·上一篇:查看流量命令 >>    ·下一篇:notepad 快捷键 >>
推荐文章
最新文章