如何将流量管理器与 Azure 存储静态网站一起使用?

How to use Traffic Manager with Azure Storage Static Website?

我在 Azure 存储静态网站中有一个带有终结点的流量管理器。 index.html 的静态网站已启动,http 和 https 上的 运行。 流量管理器中的端点状态为联机。

但是当尝试通过流量管理器 DNS 名称访问静态网站时 http://-.trafficmanager.net 我收到 400 Bad Request 错误。

错误似乎来自存储网站:

The request URI is invalid.
HttpStatusCode: 400
ErrorCode: InvalidUri

为什么?如何解决这个问题?

这是我对自己问题的回答 "How to fix?":

  1. 转到存储帐户 -> 自定义域配置

  2. 在那里输入流量管理器 DNS 名称 blahblah.trafficmanager.net 并保存配置

  3. 稍等片刻。

宾果! 现在blahblah.trafficmanager.net 显示存储帐户中的静态网站。

请注意,存储帐户必须支持 HTTP 才能正常工作。

存储帐户 -> 配置 -> 需要安全传输已禁用

仍然没有问题的答案"Why?"

我可以重现这个错误。流量管理器在 DNS 级别工作。它使用 DNS 响应将客户端重定向到适当的服务端点。因此,您看到的任何 HTTP 错误都必须来自您的应用程序。就像 the document 状态

The HTTP host header sent from the client's browser is the most common source of problems. Make sure that the application is configured to accept the correct host header for the domain name you are using.

据我了解,我们正在使用 *.trafficmanager.net 访问 blob 存储中的静态网站,默认情况下,如果没有自定义域配置,它只接受主要端点主机,如 xxx.z13.web.core.windows.net。所以我们需要在 blob 存储中添加这样的主机 *.trafficmanager.net

此外,对于使用 Azure 应用服务的端点,Azure 会在您添加应用服务端点后自动在 Azure 应用服务的自定义域中添加一个主机名 *.trafficmanager.net。你可以看到 Configuring a custom domain name for a web app in Azure App Service using Traffic Manager.

另请注意,流量管理器无法提供任何涉及 this 的证书验证。