SSL通过强制跳转增加网站的安全等级

  • A+
所属分类:运维教程

SSL通过强制跳转增加网站的安全等级

现在越来越多的网站都在使用SSL协议,提升访客在网站提交数据时的安全度。通常大家在设置好网站的SSL证书后,都会到安全度验证网站测试一下。

一般开启SSL证书后,网站的安全级别都会达到A,但是A的上面还有个A+,那这个A+要如何达到呢?网站上会提示你开启一个叫HSTS的东东,但大家千万别上当,可以看我之前写的文章《开启HSTS后的坑》就会了解有些设置是开不得。

其实开启SSL后,网站可用两种协议访问,一种是http,另一种https,后者会对数据加密,所以更加安全。而HSTS的作用就是将http协议的访问请求屏蔽,使用户只能通过https协议访问。

所以我们可以换个思路解决这个问题,将所有http请求,跳转到https,这样同样可以保障网站数据的安全性。

这里以nginx为例,在配置文件中添加如下内容即可:

  1. if ($server_port !~ 443){
  2.     rewrite ^(/.*)$ https://$host$1 permanent;
  3. }

上面代码的意思是判断访问是否来自443号端口,https对应443,而http对应是80,所以只要不是443过来的请求,都是不安全的,就跳转到https协议来处理。

  • 问答中心
  • 微信小程序扫一扫
  • weinxin
  • 微信公众
  • 微信公众号扫一扫
  • weinxin

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

目前评论:8   其中:访客  8   博主  0

    • avatar imp source

      Hey there, You have performed an excellent job. I will certainly digg it and for my part suggest to my friends. I am confident they’ll be benefited from this website.

      • avatar find more info

        I enjoy gathering utile information , this post has got me even more info! .

        • avatar erjilopterin

          I got what you intend, regards for putting up.Woh I am glad to find this website through google.

          • avatar Click Here

            Appreciate it for this wonderful post, I am glad I discovered this web site on yahoo.

            • avatar lesptitutos.fr

              I like this web site its a master peace ! Glad I noticed this on google .

              • avatar Greensboro groomers

                It¦s actually a great and helpful piece of info. I am satisfied that you shared this useful information with us. Please keep us informed like this. Thanks for sharing.

                • avatar smoretraiolit

                  Some truly excellent information, Gladiola I found this.

                  • avatar firtukloimutrzas

                    Do you mind if I quote a couple of your posts as long as I provide credit and sources back to your weblog? My blog site is in the very same niche as yours and my visitors would really benefit from some of the information you present here. Please let me know if this alright with you. Thanks!