ASP.NET IIS Web.Config 文件 - 防止防火墙绕过

ASP.NET IIS Web.Config file - Prevent firewall bypass

我正在使用 ASP 提供商并将基于 IIS 的 ASP 域指向使用名称服务器的防火墙提供商。防火墙提供商建议我通过编辑 .htaccess 文件来禁用绕过 Web.Config 安全设置的尝试,假设我使用的是 Apache。但是,ASP 使用 IIS。我确实注意到,对于 Apache,您只需要修改 .htaccess,例如使用以下代码:

<FilesMatch ".*">
    Require ip XXX.XX.XXX.X/23
    Require ip YYY.YY.YYY.Y/22

(MORE IP ADDRESS)

</FilesMatch>

更新

您可以使用 IIS 管理器或 Web.Config 设置基于 IP 地址的访问控制。本来是用IIS Manager设置IP地址访问的,现在想转成Web.Config只有下面的文件内容:

<configuration>
    <system.webServer>
                <httpRedirect enabled="true" destination="https://www.myweb.org/" />
        <directoryBrowse enabled="true" />
        <security>
            <ipSecurity allowUnlisted="false">
                <clear/>
                <add ipAddress="127.0.0.1" allowed="true"/>
                <add ipAddress="11.111.111.11" allowed="true"/>
                <add ipAddress="222.22.22.22" allowed="true"/>
            </ipSecurity>
        </security>
    </system.webServer>
    <appSettings>
        <add key="ChartImageHandler" value="storage=file;timeout=20;"/>
    </appSettings>
        <location path="Default WebSite">
        </location>
    <system.web>
          <webServices>
        <protocols>
          <add name="HttpGet"/>
          <add name="HttpPost"/>
        </protocols>
      </webServices>
          <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
          <error statusCode="403" redirect="NoAccess.htm" />
                 <error statusCode="404" redirect="FileNotFound.htm" />
                </customErrors>
    </system.web>
    <system.codedom>
    </system.codedom>
        <startup>
               <supportedRuntime version="v2.0.50727"/>
        </startup>
</configuration>

当我使用 VPN 然后使用固定 IP 地址访问站点时,访问控制现在看起来确实有点不一致和松散。有时我收到也没有收到 403 错误,有时屏幕只是白色。这可能是IIS管理器中的一些设置没有清除掉,所以有以下疑问:

  1. 有没有办法在每次访问后重置(清零)IP 访问控制设置 "Entry" 在 IIS 管理器中删除了 IP 地址?

  2. 当您使用Web.Config进行IP访问控制时,是否需要打开IIS Manager并指定-->Edit Features Settings--> Allow (Access for unspecified clients)?

  3. 我需要在 Web.Config 中的某处拒绝吗?

  4. 当 Web.Config 和 IIS 管理器为访问控制列出相同的 IP 地址时会发生什么(我认为这会导致冲突)?

据我所知,IIS 包含相同的 IP 限制设置。您可以使用 IIS 管理控制台或 web.config.

来设置它

更多详细设置方法,可参考以下步骤:

1.Open IIS 管理控制台并找到您的网站并select IP 限制。

2.Click 编辑功能设置并将未指定客户端的访问权限更改为拒绝。

3.Click 允许进入...并在特定的 ip 地址上添加一些 ip 地址