如何禁用 IIS 中的 OPTIONS 方法?

问题描述 投票:0回答:1

这是 Windows 10 计算机。 未安装 IIS 管理器。 web.config 文件不存在。

如何禁用 OPTIONS 方法?

更新:我不想安装任何附加功能。这是最小的 Windows 操作系统配置,出于安全原因禁用了许多功能。

windows security iis
1个回答
1
投票

我假设您应该具有管理员访问权限并且应该能够运行 PowerShell 脚本。您可以尝试一下此脚本片段吗?假设您想为“默认网站”执行此操作,如果有您想要的特定网站,则请将网站名称替换为适当的 SiteName 信息。

# Import the WebAdministration module
Import-Module WebAdministration

# Get the IIS site you want to modify (replace with your site name)
$siteName = "Default Web Site"
$site = Get-Website -Name $siteName

# Check if the Request Filtering module is installed
if (-not (Get-WindowsFeature Web-Filtering).Installed) {
    Install-WindowsFeature Web-Filtering -IncludeManagementTools
}

# Disable OPTIONS verb for the site
Set-WebConfigurationProperty -Location "$site/system.webServer/security/requestFiltering/verbs" -Filter "add[@verb='OPTIONS']" -Name "allowed" -Value "false"
© www.soinside.com 2019 - 2024. All rights reserved.