[原创]nginx 如何设置将http自动跳转到https – 21运维
通知: .-...

[原创]nginx 如何设置将http自动跳转到https

nginx 21运维 5121浏览 0评论

我这里总结了有两种,还有其他方法,有兴趣的朋友可以自己再去研究琢磨:
1,通过站点配置文件做重定向实现。

server {
listen 80;
server_name download.21yunwei.com;
rewrite ^(.*) https://download.21yunwei.com$1 permanent;
}
server {
        listen 443 ssl;
        ssl_certificate         /homw/wwwroot/download21/ssl/download.21yunwei.com.crt;
        ssl_certificate_key     /homw/wwwroot/download21/ssl/download.21yunwei.com.key;

        server_name download.21yunwei.com;

2,通过文件代码跳转。
站点根目录下设置一个index.html,里边设置代码:

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

百度就是这么实现的,可以测试下curl baidu.com -vv

转载请注明:21运维 » [原创]nginx 如何设置将http自动跳转到https

发表我的评论
取消评论
表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址