asp.net - 通过域名限制对网站的访问

标签 asp.net iis web-config azure-web-app-service domain-name

我正在私下测试一个与其他 API 通信的 Azure Web 应用程序。我只允许某些 IP 地址通过,如下所示:

<system.webServer>
  <security>
     <ipSecurity>
        <add allowed="true" ipAddress="192.168.100.1" subnetMask="255.255.255.0" />
     </ipSecurity>
  </security>

但是,一个 API 没有可靠的静态 IP 地址。所以我试图通过域让它通过,如下所示:

https://www.iis.net/configreference/system.webserver/security/ipsecurity/add

<system.webServer>
  <security>
     <ipSecurity>
        <add allowed="true" domainName="example.com." />
     </ipSecurity>
  </security>

文档说:“指定要对其施加限制规则的域名。您可以使用星号 (*) 作为通配符。”

我认为我的域名错误(此时只是猜测,需要查看日志),因为它不起作用。我尝试过“*.example.com”、“example.com”和“example.com”。 (末尾有点)。

这让我问:

1) 该域名字符串必须采用什么格式?我找不到任何例子。例如,它需要协议(protocol)“https”还是“http”?

2) 如何查看尝试连接到 Azure Web 应用程序的域名/IP 地址?换句话说,我如何查看相当于 fiddler 的流量?我需要验证与我的网站通信的 API 端点。

最佳答案

1) 根据日志分析,我获得了 IP 地址,然后使用在线工具将其转换为域名,我需要允许通过的域的形式如下:

subsubdomain.subdomain.example.com。

由于负载平衡,我不能只允许一个域通过。我被迫使用这个字符串,它有效:

*.subdomain.example.com

2) 我找到了相关的 IP 地址,然后使用 Kudu Web 界面将其转换为域(使用在线工具)。首先,我单击“调试控制台”,它显示文件结构,然后单击“LogFiles”,然后单击“http”,然后单击“RawLogs”。我下载了日志并在 Excel 中查看了它们。

关于asp.net - 通过域名限制对网站的访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38539739/

相关文章:

asp.net - 如何在 IIS 10 中正确自动启动 asp.net 应用程序

c# - 如何在 ASP.NET WebApi2 中管理缓存?

asp.net - 将 Windows 身份验证与 Azure WebApp/网站结合使用

.net - web.config 的 appsettings 内的标签值。如何?

c# - 已成功与服务器建立连接,但在登录前握手期间发生错误。 (无法更改 SQL Server)

c# - 如何在单击提交按钮时在 mvc4 中将文本框值从 View 获取到 Controller

asp.net - 如何在 asp.net 中找到远程主机名?

c# - 是否可以在 Asp.net Core 解决方案的单独层中管理 DBContext 的注入(inject)

asp.net - 从网站删除 SQL 成员资格

asp.net - 无法弄清楚 VS2010 中的 web.debug.config 与 web.config 替代