gpt4 book ai didi

apache - 为 Apache Tomcat 7 构建 HTTP 安全 header 过滤器

转载 作者:行者123 更新时间:2023-11-28 22:16:00 25 4
gpt4 key购买 nike

我想为我的 Apache Tomcat 7 服务器添加安全 header 。检查发现 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'"

有人可以帮助解决如何构建过滤器以伴随这些选项吗?

最佳答案

这将通过 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>

关于apache - 为 Apache Tomcat 7 构建 HTTP 安全 header 过滤器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52490240/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com