【问题标题】:Framing HTTP secure header filters for Apache Tomcat 7为 Apache Tomcat 7 构建 HTTP 安全标头过滤器
【发布时间】:2018-09-25 03:40:03
【问题描述】:

我想为我的 Apache Tomcat 7 服务器添加安全标头。检查发现 xssProtectionEnabled 过滤器需要添加到 apache tomcat 的 web.xml 文件中。

也就是说,我需要在配置中添加这些选项。

X-XSS-Protection: "1; mode=block"  
X-Content-Type-Options: nosniff 
Content-Security-Policy "script-src 'self'; object-src 'self'"

有人可以帮助了解如何将过滤器设计为伴随这些选项吗?

【问题讨论】:

    标签: apache tomcat


    【解决方案1】:

    这将通过 tomcat 过滤器 Container Provided Filters 工作,例如,有一篇文章 How to Enable Secure HTTP Header in Apache Tomcat 8? 文章将建议启用以下功能:

    <filter>
      <filter-name>httpHeaderSecurity</filter-name>
      <filter-class>org.apache.catalina.filters.HttpHeaderSecurityFilter</filter-class>
      <async-supported>true</async-supported>
    </filter>
    <filter-mapping>
      <filter-name>httpHeaderSecurity</filter-name>
      <url-pattern>/*</url-pattern>
    </filter-mapping>
    

    【讨论】:

    • 感谢 PowerStat :)
    • 这会启用 Content-Security-Policy 吗?
    猜你喜欢
    • 2015-06-11
    • 2012-01-11
    • 1970-01-01
    • 2013-06-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-02
    • 1970-01-01
    相关资源
    最近更新 更多