在Apache Tomcat 6.0中禁用PUT TRACE DELETE请求

M.N*_*M.N 10 tomcat http application-server security-constraint

我需要在我的Application Server,Apache Tomcat 6.0上禁用PUT,DELETE和TRACE HTTP请求.

所有其他来源,我已经搜索到现在,已经指示我走向httpd.conf中的limit参数,因此我事先说明我没有使用Apache Web Server,并且请求直接由Tomcat处理,并且所以图片中没有httpd.conf.

请建议我如何在Tomcat上进行操作?

Jam*_*hek 19

在您的WEBINF中,添加您可以添加安全约束:

<security-constraint>
     <web-resource-collection>
          <web-resource-name>Forbidden</web-resource-name>
          <url-pattern>/blah/*</url-pattern>
          <http-method>PUT</http-method>
          <http-method>DELETE</http-method>
          <http-method>TRACE</http-method>
     </web-resource-collection>
     <auth-constraint>
          <role-name>empty_role</role-name>
     </auth-constraint>
</security-constraint>
Run Code Online (Sandbox Code Playgroud)

或者,您可以执行以下两项操作:

在server.xml中,编辑<connector>元素,添加属性:allowTrace="false".然后编辑DefaultServlet:$ CATALINA_HOME/conf/web.xml

<servlet>
    <servlet-name>default</servlet-name>
    <servlet-class>
        org.apache.catalina.servlets.DefaultServlet
    </servlet-class>
    <!-- blah blah blah -->
    <init-param>
        <param-name>readonly</param-name>
        <param-value>true</param-value>
    </init-param>
</servlet>
Run Code Online (Sandbox Code Playgroud)