Tomcat安全配置之启用了不安全的HTTP方法 tomcat
使用OPTIONS方法列出服务器使用的HTTP方法。注意,不同目录中激活的方法可能各不相同。
许多时候,被告知一些方法有效,但实际上它们并不能使用。有时,即使OPTIONS请求返回的响应中没有列出某个方法,但该方法仍然可用。
tomcat,配置web.xml
<security-constraint>
<web-resource-collection>
<web-resource-name>fortune</web-resource-name>
<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>
</web-resource-collection>
<auth-constraint></auth-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
</login-config>
重启tomcat即可完成。
以上的代码添加到某一个应用中,也可以添加到tomcat的web.xml中,区别是添加到某一个应用只对某一个应用有效,如果添加到tomcat的web.xml中,则对tomcat下所有的应用有效。
如有疑问 请留言 欢迎提供建议
评论已有 0 条