IIS7.0默認開啟了不安全的OPTIONS和TRACE方法,建議關閉這兩個方法。
以下環境為Windows Server 2008、IIS7.0
方法(1):web.config
在<configuration>節點下添加如下代碼:
<system.webServer> <security> <requestFiltering> <verbs allowUnlisted="false"> <add verb="GET" allowed="true"/> <add verb="POST" allowed="true"/> <add verb="HEAD" allowed="true"/> </verbs> </requestFiltering> </security></system.webServer>
以上代碼只允許開啟GET、POST和HEAD方法。
allowUnlisted="false":拒絕未列出的謂詞。
方法(2):IIS7.0 --> “授權規則”
添加“允許”和“拒絕”規則,特定謂詞只能填一個。
方法(3):IIS7.0 --> applicationHost.config
文件位置:C:/Windows/System32/inetsrv/config/
若要配置 IIS 處理未列出的謂詞的方式,請使用以下語法:
appcmd set config /section:requestfiltering /verbs.allowunlisted:true | false
例如,若要拒絕未列出的謂詞,請在命令提示符處鍵入以下命令,然后按 Enter:
appcmd set config /section:requestfiltering /verbs.allowunlisted:false
若要配置要篩選的謂詞,請使用以下語法:
appcmd set config /section:requestfiltering /+verbs.[verb=' string ',allowed='true | false']
變量 verbstring 用于指定將應用此限制的謂詞。
例如,若要指定允許使用 GET,請在命令提示符處鍵入以下命令,然后按 Enter:
appcmd set config /section:requestfiltering /+verbs.[verb='GET',allowed='true']
參考文獻:
http://technet.microsoft.com/zh-cn/library/86bb183f-a016-40ca-b9c3-bbb2f5c8a4b5.aspx
http://www.iis.net/learn/manage/configuring-security/use-request-filtering
http://technet.microsoft.com/zh-cn/library/hh831621
新聞熱點
疑難解答