【问题标题】:Blocking access to a url by IP address通过 IP 地址阻止对 url 的访问
【发布时间】:2015-09-10 12:18:20
【问题描述】:

出于安全原因,我正在尝试阻止对 Umbraco (v7.2.8) 的管理员 URL 的所有访问。我的 web.config 文件中有以下内容,但它不起作用。它阻止了对该 URL 的所有访问,即使是来自指定 IP 的访问。我从 Visual Studio 在我的机器上本地运行它,所以我不确定该网站认为我要进入的 IP,但我已经尝试了所有这些。这个 web.config 看起来不错吗?

  <rewrite>
  <rules>
    <rule name="Restrict URL" enabled="true" stopProcessing="true" >
      <match url="^umbraco($|/)"/>
      <conditions logicalGrouping="MatchAll">

        <add input="{REMOTE_ADDR}" pattern="^192\.168\.8\.100$" negate="true" />

       </conditions>
      <action type="Redirect" url="/no-access/" /> 
    </rule>
  </rules>

任何指针将不胜感激!我最终将把它部署到 Azure,但想先让它工作。也许是因为我在本地运行它?

编辑:我尝试了 ipSecurity 解决方案,但收到以下错误。我已经为 IIS 安装了 IP 安全组件。我正在从 Visual Studio 运行该站点,所以我不确定是否可以从这里在 VS 使用的快速服务上对其进行测试?我还在以下文件中更改为“允许”;

%windir%\system32\inetsrv\config\applicationHost.config

【问题讨论】:

  • 你将如何部署它? Web 应用还是云服务?
  • 我会将其部署为网络应用程序。
  • 这只是显示错误在哪里,而不是错误是什么。您还需要在编辑中包含 web.config 的适用部分。如果在您的本地计算机上启用了 ipSecurity,则 IIS express 将起作用 - 请参阅我的答案中引用的链接。最后,我不会对 applicationHost.config 进行任何手动更改来尝试使其正常工作,因为您将无法在 Azure WebApps 上复制该解决方案。

标签: azure iis url-rewriting web-config umbraco


【解决方案1】:

使用 location 元素内 web.config 中的 system.webServer >> security >> ipSecurity 设置更容易实现:

<location path="umbraco">
  <system.webServer>
    <security>
      <ipSecurity allowUnlisted="false" denyAction="NotFound">
        <add allowed="true" ipAddress="192.168.8.100" />
      </ipSecurity>
    </security>
  </system.webServer>
</location>

更多详情请参阅IIS IP Security。在 Azure WebApps 上默认启用 IP 安全性。

【讨论】:

  • 嗨 - 我已经尝试过这个解决方案,但得到了上面的错误(在我的帖子中编辑)。我将尝试部署到 azure 并查看这是否有效,正如您所说的 azure 默认启用此功能。会通知您并更新答案。
猜你喜欢
  • 1970-01-01
  • 2014-12-16
  • 2019-03-17
  • 2016-07-20
  • 2020-03-06
  • 2011-03-16
  • 2015-10-18
  • 2010-11-04
  • 2011-11-17
相关资源
最近更新 更多