TOMCAT禁用不安全请求方式

查看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>
posted @ 2017-08-06 11:30  元页  阅读(2136)  评论(0编辑  收藏  举报