我的 Azure 网站在(监视器)门户中有一个奇怪的 "HTTP success" 模式

My Azure Website has an odd "HTTP success" pattern in the (Monitor) portal

我在 Azure Websites 中托管了一个网站作为 Basic 层网站。 我目前正处于开发阶段,但该站点已经上线并可供外界访问(至少在基本级别),因此我想更好地了解 Azure 管理门户中的监视功能。

当我查看门户内的监控选项卡时,我发现 HTTP success 有一个奇怪的模式。看看过去的60分钟(我个人没有活跃),HTTP successes非常循环,有80个连接, 然后 0, 然后 40, 然后 0, 然后重复.

有没有人能告诉我如何弄清楚 8040 连接是什么。我的代码中当然没有任何定时事件,因此除非有人实际访问该网站,否则不应进行任何调用。

更新:

我设置了一个临时服务器并阻止了除我自己的 IP 之外的所有传入流量。所以相同的代码 运行,只是无法从外界访问。 HTTP success 只有在我自己访问服务器时才会出现(如预期的那样)。这表明我的网站可能被外部机器人攻击了? 有人知道如何防止这种情况吗? 或者至少诊断请求是否合法等?

您可能想先了解这些请求是什么。在 Azure 管理门户上为网站启用 Web 服务器日志记录,并在看到此模式后为您的网站下载 IIS 日志。然后检查那些以了解 URL、请求的客户端 ip 地址和用户代理字段,以确定请求是否真的来自搜索机器人。根据观察,您可以静态禁用某些 IP,使用动态 ip 限制或配置 URLREWRITE 以阻止请求中具有特定模式的请求或请求 headers

编辑 这是阻止搜索机器人的方法 - http://moz.com/ugc/blocking-bots-based-on-useragent

您可以按照上述文章中描述的方式在IIS服务器上本地配置URLREWRITE,然后复制web.config中生成的配置或直接使用IIS连接到azure网站http://azure.microsoft.com/blog/2014/02/28/remote-administration-of-windows-azure-websites-using-iis-manager/ 中描述的管理器并配置 urlrewrite 规则

我会说是这个设置导致了流量:

Always On. By default, websites are unloaded if they are idle for some period of time. This lets the system conserve resources. In Basic or Standard mode, you can enable Always On to keep the site loaded all the time. If your site runs continuous web jobs, you should enable Always On, or the web jobs may not run reliably

http://azure.microsoft.com/en-us/documentation/articles/web-sites-configure/

每次您或其他人访问您的网站时,这只是一个 keep alive 以避免冷启动。

Here's 另一个描述此行为的参考资料:

What the always-on feature does is simply ping your site every now and then, to keep the application pool up and running.

Scott Gu says

One of the other useful Web Site features that we are introducing today is a feature we call “Always On”. When Always On is enabled on a site, Windows Azure will automatically ping your Web Site regularly to ensure that the Web Site is always active and in a warm/running state. This is useful to ensure that a site is always responsive (and that the app domain or worker process has not paged out due to lack of external HTTP requests).

关于一般流量:首先,请求实际上只能来自 Microsoft,因为在使用 Azure 时,任何像这样的流量模式都会很快被自动检测和阻止网站 - 你不能自己建立一个这样的网站。其次,任何现代机器人都不会以这种规律性地定期 ping 特定页面,因为这很明显。任何现代数据中心安全设备都会捕捉到这种流量并 block/ignore/nullroute 它。

关于您关于保护和安全的问题:Microsoft 无法保护您的代码免受您自己的侵害。但是,外围的一切都由 Microsoft 管理和处理。这是 Azure 的 USP 功能之一——防火墙、负载平衡、欺骗、反机器人和 DDOS 保护等。当然,任何公开服务都会存在安全问题,但你可以专注于你的应用程序,而 Microsoft 会管理其余部分.

当 运行使用 Azure 网站时,您在应用程序范围之外的安全方面掌握在 Microsoft 手中。这是一件好事,但如果您真的希望能够使用其他安全措施,则必须设置一个虚拟机,然后从那里 运行 您的网站。