Why use subdomains to designate tenants in a multi-tenant web application?

和自甴很熟 提交于 2019-12-31 08:28:06

问题


Questions

  1. Why do some multi-tenant web applications use subdomains to designate the tenant while others do not?
  2. Are there technical, privacy, or security reasons?
  3. Is it dependent on the language or framework used to develop the web application?
  4. Is it simply a matter of style or developer's choice?

Example Web Applications Using Subdomains to Designate Tenants

  • Basecamp
  • RepositoryHosting
  • Smugmug
  • Unfuddle

Example Web Applications Not Using Subdomains to Designate Tenants

  • Github
  • ThinMind
  • Bitbucket

回答1:


There are several ways to determine tenant on HTTP level:

  • domain - tenant is determined by whole Host header
  • sub-domain - sub-domain part of Host header,
  • path based - path segment, usually by prefix host.com/tenantId/...
  • cookie based - cookie value contains tenant id (good framework encrypts this!)
  • user based - user session or some data records on server

Here are an answers to your questions:

  1. (Sub-)domain multi-tenancy is good if you want to give an user a perception of fully isolated tenancy. The customer may want custom welcome and login page, separate user-base etc. On the other hand the path based multi-tenancy is good for the users who are not fixed to single tenant namespace. It is mostly used by social networks like Facebook, GitHub etc.

  2. (Sub-)domains can give you better isolation and security control for cookies, cross-origin resources sharing (CORS). It makes cross-tenant CSRF or XSS a bit harder. Moreover if you have control over DNS or Load-balancer you can assign tenants to different IPs (think geo-routing) or to various versions of application (e.g. beta tenants). You can assign a separate app instance or server for your most important tenants. This way you get a cheap tool to control risk of single point of failure and all eggs in one basket.

  3. Any web-framework which gives you an access to HTTP headers (Host) is sub-domains capable. Any serious MVC web-framework should give you sub-domain as action parameter directly or by plugin.

  4. It is definitely a design choice. If you want to know the best way think what level of isolation you want for your tenants. If you decide but you will find that the way is not right then you can migrate to another level with help of HTTP 301 redirection.




回答2:


  1. See below.
  2. Cookies would be the most obvious, with the second being that you can change DNS settings for a subdomain but not for a path
  3. No
  4. Partially, see above.


来源:https://stackoverflow.com/questions/4987201/why-use-subdomains-to-designate-tenants-in-a-multi-tenant-web-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!