如何在码头服务器中禁用http选项方法

问题描述 投票:1回答:1

我继承了一个使用码头的战争文件。我想禁用HTTP方法选项。

我对码头服务器不熟悉。请帮助我在步骤中禁用HTTP方法

jetty war http-method
1个回答
1
投票

这是标准Servlet规范支持的。

编辑战争的WEB-INF/web.xml并针对url模式添加安全约束以拒绝使用OPTIONS方法。

示例。

<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee 
  http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
  version="3.1">

  <!-- ... other configurations ... -->

  <security-constraint>
    <web-resource-collection>
      <web-resource-name>Restricted HTTP Methods</web-resource-name>
      <url-pattern>/*</url-pattern>
      <http-method>OPTIONS</http-method>
      <http-method>TRACE</http-method>
    </web-resource-collection>
    <auth-constraint />
  </security-constraint>
</web-app>
© www.soinside.com 2019 - 2024. All rights reserved.