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