如何禁止tomcat中DELETE、PUT、OPTIONS、TRACE这些方法?

oldbig 2017-11-21 04:43:25
我们的系统用tomcat,客户方要进行安全测评,非说DELETE、PUT、OPTIONS、TRACE这些方法不安全,要在tomcat中禁掉。
我查了下解决方法,无非是在web.xml中添加如下代码:

<security-constraint>
<web-resource-collection>
<url-pattern>/*</url-pattern>
<http-method>PUT</http-method>
<http-method>DELETE</http-method>
<http-method>HEAD</http-method>
<http-method>OPTIONS</http-method>
<http-method>TRACE</http-method>
</web-resource-collection>
<auth-constraint>
</auth-constraint>
</security-constraint>


我们也这么设置了,然后他们使用curl 来检测:
curl -i -X OPTIONS http://127.0.0.1:8080/404/
这个就是一个不存在的地址来看返回的响应头,结果是这样的:



客户那边坚持说是有这个Allow: GET, HEAD, POST, PUT, DELETE, OPTIONS就不行

请教达人:那么这个PUT,DELETE这些方法倒底是禁了还是没禁?如何能让这个输出的响应头中把这个Allow去掉?
...全文
2336 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
shulizong 2019-07-24
  • 打赏
  • 举报
回复
我也是,在后台禁用了,但是还是能提交到服务器上去,返回403
季末荳芓 2018-09-07
  • 打赏
  • 举报
回复
<security-constraint>
<web-resource-collection>
<web-resource-name>NoAccess</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint/>
</security-constraint>
<security-constraint>
<web-resource-collection>
<web-resource-name>AllowedMethods</web-resource-name>
<url-pattern>/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
</security-constraint>

5,655

社区成员

发帖
与我相关
我的任务
社区描述
Web开发应用服务器相关讨论专区
社区管理员
  • 应用服务器社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧