查看tomcat日志,发现有些请求方式是CONNECT、HEAD,不是正常的请求,决定禁掉这样的。在web.xml上加上下面代码可以禁掉这些请求方式,以这些方式请求服务tomcat将会返回403状态。

(加在tomcat/conf/web.xml下会对整个tomcat生效,加在单个项目下只会对这个项目生效)

<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>
        <http-method>CONNECT</http-method>
    </web-resource-collection>  
    <auth-constraint></auth-constraint>  
</security-constraint>

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-10
  • 2021-11-18
  • 2021-10-16
  • 2021-06-19
  • 2021-05-17
猜你喜欢
  • 2022-12-23
  • 2021-07-25
  • 2022-12-23
  • 2021-08-10
  • 2022-01-01
  • 2021-10-09
相关资源
相似解决方案