Apache实现:HSTS、HPKP头部署方法

一、Apache HSTS 部署

 

#启用HTTP严格传输安全

Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains"

 

#HSTS策略只能在加密通道的HTTP响应中进行设置,因此需要把http重定向到https,如果明文响应中允许设置HSTS头,中间人攻击者就可以通过在普通站点中注入HSTS信息来执行DoS攻击;

<VirtualHost *:80>

ServerName www.example.com

ServerAlias example.com

#将所有访问者重定向到加密的网站

RedirectPermanent / https://www.example.com/

<VirtualHost>

 

给大家一个简单的示例代码:

# Optionally load the headers module:

LoadModule headers_module modules/mod_headers.so

<VirtualHost 0.0.0.0:443>

Header always set Strict-Transport-Security "max-age=63072000; includeSubdomains; preload

</VirtualHost>

 

Apache实现:HSTS、HPKP头部署

 

二、Apache HPKP 部署

下面的例子固定到 COMODO RSA Domain Validation Secure Server CA 及备份的 Comodo PositiveSSL CA 上,30天失效期,包括所有的子域。

 

编辑你的 Apache 配置文件(如 /etc/apache2/sites-enabled/website.conf 或 /etc/apache2/httpd.conf),并添加下列行到你的 VirtualHost 中:

 

# 如需要,载入 headers 模块。

LoadModule headers_module modules/mod_headers.so

Header set Public-Key-Pins "pin-sha256=\"klO23nT2ehFDXCfx3eHTDRESMz3asj1muO+4aIdjiuY=\"; pin-sha256=\"633lt352PKRXbOwf4xSEa1M517scpD3l5f79xMD9r9Q=\"; max-age=2592000; includeSubDomains"

    A+
发布日期:2017年04月26日 19:10:00  所属分类:经验
最后更新时间:2018-10-19 13:46:28
标签:
付杰
  • ¥ 0.0元
  • 市场价:199.0元
  • ¥ 169.0元
  • 市场价:299.0元
  • ¥ 159.0元
  • 市场价:398.0元
  • ¥ 298.0元
  • 市场价:498.0元

发表评论

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