[轻微]WEB服务器启用了OPTIONS方法/如何禁止DELETE,PUT,OPTIONS等协议访问应用程序/tomcat下禁用不安全的http方法...
生活随笔
收集整理的這篇文章主要介紹了
[轻微]WEB服务器启用了OPTIONS方法/如何禁止DELETE,PUT,OPTIONS等协议访问应用程序/tomcat下禁用不安全的http方法...
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
使用了360網(wǎng)站安全檢測 查到有OPTIONS方法
百度了下?https://my.oschina.net/maliang0130/blog/338725
找到這個(gè)方法奈何http.conf 找不到無論在tomcat目錄里還是linux路徑下的/usr/etc或者apache2
最后通過開源中國找到
第一步:修改應(yīng)用程序的web.xml文件的協(xié)議
<?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">第二步:在應(yīng)用程序的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即可完成
如果用戶要驗(yàn)證既可以將POST和GET也添加在其中,重新部署并啟動(dòng)tomcat即可看到效果
以上的代碼添加到某一個(gè)應(yīng)用中,也可以添加到tomcat的web.xml中,區(qū)別是添加到某一個(gè)應(yīng)用只對(duì)某一個(gè)應(yīng)用有效如果添加到tomcat的web.xml中,則對(duì)tomcat下所有的應(yīng)用有效。
<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>轉(zhuǎn)載于:https://www.cnblogs.com/shanheyongmu/p/5978346.html
總結(jié)
以上是生活随笔為你收集整理的[轻微]WEB服务器启用了OPTIONS方法/如何禁止DELETE,PUT,OPTIONS等协议访问应用程序/tomcat下禁用不安全的http方法...的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: PageLayoutControl的基本
- 下一篇: 油价回调只是暂时的!能源专家:年底前有望