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



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

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

这是标准Servlet规范支持的。

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

例。

<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>

最新更新