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>


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM