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:

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

    • avatar website hosting services

      Hi there mates, fastidious post and pleasant arguments commented here, I am really enjoying by these.

      • avatar web hosting providers

        This information is worth everyone’s attention. When can I find out more?

        • avatar grolyrtolemcs

          You really make it seem really easy along with your presentation however I to find this topic to be really one thing which I believe I might by no means understand. It sort of feels too complex and extremely wide for me. I am looking ahead in your next publish, I¦ll try to get the hang of it!

          • avatar best hosting

            This excellent website truly has all of the information I wanted about this subject and didn’t know
            who to ask.

            • avatar web hosting service

              If you want to improve your experience only keep visiting this web page and be updated with the hottest news update posted here.

              • avatar web hosting providers

                Wow, this paragraph is fastidious, my sister is analyzing these
                kinds of things, thus I am going to inform her.

                • avatar this site

                  Dead written subject matter, Really enjoyed studying.

                  • avatar click to read

                    I truly prize your work, Great post.

                    • avatar best web hosting sites

                      Good day very cool website!! Man .. Beautiful
                      .. Superb .. I’ll bookmark your website and take the feeds also?
                      I am satisfied to search out numerous useful information here within the
                      publish, we’d like work out extra techniques in this regard,
                      thanks for sharing. . . . . .