将单独的应用服务托管为网站目录

Hosting a separate app service as a website directory

是否可以将单独的 Azure 应用服务作为另一个应用服务的一部分包含在内?

例如,假设我有一个名为 www.mycompany.com 的网站托管在它自己的 Azure 应用服务中。我有另一个 Azure 应用服务,我想通过转到第一个应用服务中的特定 URL 来访问它。

换句话说,当请求到达 www.mycompany.com/eu/ 时,我希望从其他应用服务提供此端点 (/eu) 的内容。负载均衡器会起作用吗?我想这样做的原因是因为 /eu 端点变得太大了,我想将它与主站点分开并将其托管在单独的应用程序服务上。我希望我的问题很清楚。

提前致谢。

为此,您可以使用应用程序网关。

从某种意义上说,它类似于您所说的负载均衡器(实际上是 L7 LB),但该产品提供了许多附加功能。

下图摘自产品文档,解释了它的工作原理:

基本上,如 aforementioned docs 中所述,在描述应用程序网关如何接受请求时(注意他们在解释中提到 WAF,一个可选的安全威胁预防系统):

  1. Before a client sends a request to an application gateway, it resolves the domain name of the application gateway by using a Domain Name System (DNS) server. Azure controls the DNS entry because all application gateways are in the azure.com domain.

  2. The Azure DNS returns the IP address to the client, which is the frontend IP address of the application gateway.

  3. The application gateway accepts incoming traffic on one or more listeners. A listener is a logical entity that checks for connection requests. It's configured with a frontend IP address, protocol, and port number for connections from clients to the application gateway.

  4. If a web application firewall (WAF) is in use, the application gateway checks the request headers and the body, if present, against WAF rules. This action determines if the request is valid request or a security threat. If the request is valid, it's routed to the backend. If the request isn't valid and WAF is in Prevention mode, it's blocked as a security threat. If it's in Detection mode, the request is evaluated and logged, but still forwarded to the backend server.

到一个或另一个后端的路由可以基于 URL Paths:

您可以在 this related Microsoft article 中找到此配置的示例。

在您的用例中,您需要定义两个后端,一个用于每个应用服务,并根据需要定义路由规则。

如前所述,您的 DNS 应指向应用程序网关:它将根据客户端提供的 /eu/*/* 路由处理到一个或其他应用服务的路由.

路由的顺序很重要:匹配规则后,将处理该规则。

应用程序网关是一项区域性服务:Azure Front Door 在全球范围内利用类似的功能(以及更多)。

请考虑查看这些服务的相关费用。