[轻微]WEB服务器启用了OPTIONS方法/如何禁止DELETE,PUT,OPTIONS等协议访问应用程序/tomcat下禁用不安全的http方法...
生活随笔
收集整理的這篇文章主要介紹了
[轻微]WEB服务器启用了OPTIONS方法/如何禁止DELETE,PUT,OPTIONS等协议访问应用程序/tomcat下禁用不安全的http方法...
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
使用了360網站安全檢測 查到有OPTIONS方法
百度了下?https://my.oschina.net/maliang0130/blog/338725
找到這個方法奈何http.conf 找不到無論在tomcat目錄里還是linux路徑下的/usr/etc或者apache2
最后通過開源中國找到
第一步:修改應用程序的web.xml文件的協議
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">第二步:在應用程序的web.xml中添加如下的代碼即可
<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> </web-resource-collection> <auth-constraint> </auth-constraint> </security-constraint> <login-config> <auth-method>BASIC</auth-method> </login-config>?重新部署程序,重啟tomcat即可完成
如果用戶要驗證既可以將POST和GET也添加在其中,重新部署并啟動tomcat即可看到效果
以上的代碼添加到某一個應用中,也可以添加到tomcat的web.xml中,區別是添加到某一個應用只對某一個應用有效如果添加到tomcat的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>?? ???</web-resource-collection>?? ???<auth-constraint>?? ???</auth-constraint>?? ?</security-constraint>?? ?<login-config>?? ???<auth-method>BASIC</auth-method>?? ?</login-config>轉載于:https://www.cnblogs.com/shanheyongmu/p/5978346.html
總結
以上是生活随笔為你收集整理的[轻微]WEB服务器启用了OPTIONS方法/如何禁止DELETE,PUT,OPTIONS等协议访问应用程序/tomcat下禁用不安全的http方法...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: PageLayoutControl的基本
- 下一篇: keil5中文乱码的解决