You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Azure AppService:multitenant application跨datacenter子域名定向跳转咨询

实现Azure多租户区域重定向的方案

Absolutely, you can pull off this multi-tenant regional routing setup on Azure without a hitch—here's a clear, actionable breakdown to make it happen:

1. 先搞定基础DNS配置

First, you need to point all your tenant subdomains to an Azure routing service (either Front Door or Traffic Manager). You can do this via your domain registrar or Azure DNS:

  • Create a CNAME record for tenant1.domain.com pointing to your Azure routing service's endpoint (e.g., your-fd-endpoint.azurefd.net for Front Door)
  • Repeat the same for tenant2.domain.com, tenant3.domain.com, and all other tenant subdomains—they all point to the same routing service endpoint

2. 选择核心路由服务:Azure Front Door(推荐)或 Azure Traffic Manager

Azure Front Door (Layer 7, ideal for web apps)

This is the best pick because it supports fine-grained hostname-based routing, plus built-in CDN, WAF, and SSL management. Here's how to set it up:

  • Create a Front Door instance: Set up a frontend hostname (like your-fd-endpoint.azurefd.net), then add all your custom tenant subdomains to Front Door's custom domains. Use Azure Managed Certificates to handle SSL for all subdomains easily.
  • Configure routing rules:
    1. Create backend pools for each region: For example, US-Backend-Pool pointing to your US-region App Service, EU-Backend-Pool pointing to your EU-region App Service.
    2. Add a routing rule for each tenant:
      • Set the match condition to "Hostname equals tenant1.domain.com"
      • Set the route type to either "Forward" (keeps the subdomain visible to users, recommended) or "Redirect" (sends users to the backend's direct URL if needed)
      • Assign the rule to the corresponding backend pool (e.g., US-Backend-Pool for tenant1)
    3. Repeat this rule setup for every tenant-subdomain-to-region pairing.

Azure Traffic Manager (Layer 3/4, simpler scenarios)

If you don't need Front Door's advanced features, Traffic Manager can work too:

  • Create a Traffic Manager profile: Choose a routing method (we'll use custom hostname matching here)
  • Add endpoints for each regional App Service instance
  • Use DNS CNAME records to map each tenant subdomain to a specific Traffic Manager endpoint, or use Traffic Manager's custom routing rules to route based on incoming hostnames (note: this requires using the "Priority" or "Weighted" routing method with endpoint filters)

3. 租户识别(可选但推荐)

Once traffic reaches the correct regional App Service, your app should confirm the tenant identity:

  • Add app settings to each App Service instance: For example, set TENANT_ID=tenant1 and REGION=US in your US App Service, so your app can read these environment variables to handle tenant-specific logic.
  • Alternatively, parse the incoming request's Host header directly to extract the tenant subdomain (e.g., tenant1 from tenant1.domain.com).

4. 测试 & 验证

  • Use tools like curl or your browser to access each tenant subdomain, and verify traffic lands in the correct region (check App Service logs, or use the X-Azure-FD-Origin header if using Front Door to confirm the backend).
  • Test SSL connectivity to ensure all subdomains load securely.

内容的提问来源于stack exchange,提问作者user2818430

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 08:51:17