小岑博客

  • 首页
  • VMware
  • 实验室
  • 培训&认证
  • 关于我
  • 分类目录
    • Citrix
    • Linux
    • Windows
    • 互联网
    • 存储
    • 虚拟化
    • 超融合
  1. 首页
  2. Linux
  3. 正文

博客https安全优化到A+

2016年8月28日 5290点热度 0人点赞 8条评论

小岑博客ssllab本来的测试为A+,但是mozilla安全测试为D,于是优化了一下,得到了A+,不过安全是把双刃剑。具体适不适合各位,观众们需要自己斟酌了。
SSl测试
https://securityheaders.io/
https://mozilla.github.io/http-observatory-website/ 这个测试比较严格
主要是以下内容优化,仅仅为nginx的配置,大家在server段加入即可
1.Strict-Transport-Security
add_header Strict-Transport-Security "max-age=31536000; includeSubdomains; preload";
2.X-Frame-Options
add_header X-Frame-Options SAMEORIGIN;
3.X-Content-Type-Options
add_header X-Content-Type-Options nosniff;
4.X-XSS-Protection
add_header X-XSS-Protection "1; mode=block";
5.Content-Security-Policy
该项为资源策略,大家把自己外链的资源地址加入即可
add_header Content-Security-Policy "script-src 'self' https://duoshuo.com;img-src data: https: https://duoshuo.com";
6.Public-Key-Pins
这个需要用ssl工具计算出自己的pin-sha256的pin,计算方式在后面
add_header Public-Key-Pins 'pin-sha256="47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU="; pin-sha256="tewDBI59geBDDqF5mhU3o0wnlM98bBvMK+Z8oAp6B1g="; max-age=2592000';
计算方法
RSA key
$ openssl rsa -in my.key -outform der -pubout | openssl dgst -sha256 -binary | openssl enc -base64
ECDSA (例如 COMODO ECC )
$ openssl ec -in my.key -outform der -pubout | openssl dgst -sha256 -binary | openssl enc -base64
大家把上述生成的key填入即可,模版如下
add_header Public-Key-Pins 'pin-sha256="ABCD"; pin-sha256="EFGI"; max-age=2592000';

以下是小岑本次安全优化的配置部分
add_header Strict-Transport-Security "max-age=31536000; includeSubdomains; preload";
add_header X-Frame-Options SAMEORIGIN;
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
add_header Content-Security-Policy "script-src 'self' https://duoshuo.com;img-src data: https: https://duoshuo.com";
add_header Public-Key-Pins 'pin-sha256="47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU="; pin-sha256="tewDBI59geBDDqF5mhU3o0wnlM98bBvMK+Z8oAp6B1g="; max-age=2592000';

本作品采用 知识共享署名-非商业性使用 4.0 国际许可协议 进行许可
标签: 暂无
最后更新:2016年8月28日

小岑

我是小岑,欢迎来到我的博客,青年人,爱捣鼓些东西,对世界充满着好奇,热爱旅游。 这里随便写写,记录些文字,大抵和技术相关。 VMware vExpert | VCIX | VCAP | VCP

点赞
< 上一篇
下一篇 >

文章评论

  • tony

    附上duoshuo,和cnzz的代码
    add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' blob: https://*.duoshuo.com https://*.cnzz.com; img-src 'self' data: https://*.duoshuo.com; style-src 'self' 'unsafe-inline' https://*.duoshuo.com; connect-src wss://*.duoshuo.com:* https://*.duoshuo.com";

    2016年8月28日
    回复
  • ivmm

    博主再优化一下速度吧。 我浙江电信打开真心慢

    2016年8月28日
    回复
    • tony

      @ivmm 站点在国外。。。考虑是不是要搬回来!

      2016年8月28日
      回复
    • ivmm

      @ivmm 不至于,用七牛、又拍缓存静态内容可解

      2016年8月28日
      回复
    • tony

      @ivmm 哈哈,之前用的七牛,后来要身份证,就没用了。。。在观望香港vps...

      2016年8月29日
      回复
    • ivmm

      @ivmm 主要就是静态资源加载太慢

      2016年8月29日
      回复
    • tony

      @ivmm 已经搬回国内了!!现在速度应该不错了!

      2016年9月8日
      回复
    • ivmm

      @ivmm 舒服了好多

      2016年9月8日
      回复
  • 取消回复

    小岑

    我是小岑,欢迎来到我的博客,青年人,爱捣鼓些东西,对世界充满着好奇,热爱旅游。 这里随便写写,记录些文字,大抵和技术相关。 VMware vExpert | VCIX | VCAP | VCP


    COPYRIGHT © 2022 crazycen.com. ALL RIGHTS RESERVED.

    Theme Kratos Made By Seaton Jiang

    鄂ICP备16016796号-1