简体   繁体   中英

Unique CNAME for each Client MVC

I am at the early stages of designing a new MVC SaaS application that will need to cater for multiple clients. Each client will have multiple user accounts.

My initial thoughts is to allow each client to have their own unique URL using different CNAMES:

ie clientA.mynewmvcsite.com or clientB.mynewmvcsite.com

I see this frequently across the web with sites that implement such a model (eg BeanStalkSVN, InvoiceMachine etc)

My question really is about how this is achieved (at a high level)? I understand the use of CNAMES and DNS pointers from an IIS configuration perspective but I would guess that that is not how this is achieved.

Does it work by the web application extracting the CNAME from the request and validating that the client is valid? (most likely via querying a client list in the database - but I am not looking for specifics so I am not concerned with that part)

Due to the potential for large numbers of clients I would presume that the DNS resolution is set-up as a global rule that *.mynewwebsite.com resolves to the host server?

Any more detailed information or direction would be gladly received.

You would indeed do this by pointing all subdomains to the same place via DNS. You can then detect which one the client is using by reading the HTTP Host header, which contains the entire hostname used for the request. This header is mandated by HTTP 1.1, and is what makes virtual hosts and such possible.

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