简体   繁体   中英

How to use IIS as gateway for multi-tenant application, forwarding to different servers based on subdomain

Today I have an ASP.NET application where each of dozens of tenants (ie customers) have their own URLs, eg 'A Company' would have https://acompany.awesomeservice.com . I'm using DNS to direct all tenants to the production web server.

I'd like to have multiple production web servers and assign each subdomain to a single server. eg so tenants A, B, C use Server 1 and tenants D, E, F use Server 2. But I don't want to use DNS for this as I'd like to be able to move a tenant to a different web server reasonably fast, for green-blue deployments etc. For example, when doing upgrades I might:

  • move all tenants to Server 1
  • upgrade Server 2
  • move some tenants back who want the new version first
  • move remaining tenants some days later when everything seems stable

It seems like using IIS URL Rewrite module is an appropriate way to do it. I'd have a separate IIS server or web site for the 'gateway' and have a separate rule per tenant, rewriting the URL to whichever server they have been allocated.

But is this the right way to do it? How does everyone else do it?

I'd create a tool for allocating tenants to different servers, which would use some IIS api to update the URL Rewrite rules (which API?).

As @Lex-Li said in a comment, yes you can do a reverse proxy with ARR & URL Rewrite module and that's what I went with.

A couple of other handy links:

To update the rules via API, use IIS Administration API or update the config files directly (yuck?.). There's other APIs available too depending on needs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM