Multiple customer instances of an application, under a single application.
What I need is to allow multiple users, to connect to my Apache Web server, by passing different url like :
customer1.myhost.com
company1.myhost.com
company2.myhost.com
etc.
What I want my Apache server to do, is pass all request that are not directed to a certain list of existing hosts
(like trac.myhost.com and https://myhost.com) over to my Rails application, by setting a RequestHeader to identify the requested host, something like :
RequestHeader “INSTANCE_NAME” = customer1 #for customer1.myhost.com
Thanks for your help!
Ps.: The end goal is to offer software slices as a service, but having all those customers managed under 1 application running. Not 1 app per customer.
Using a standard VirtualHost configuration you can do this:
This will capture all requests that are not already captured by other VirtualHost entries.
When your application receives the request, you will have the request variable set with the host-name provided. This is available to any ActionController:
From there you can load the appropriate data in some kind of before_filter, as is typically done like:
So long as the client has the hostname populated correctly, this will find them on each page load.