简体   繁体   中英

Cloud Foundry Rails - Multi-tenancy based on subdomain

My rails application currently works as follows:

In the database, there are tenants, also known as 'companies'. Everything in the database belongs to one of these companies, and so have a company_id attribute in order to separate them.

My application determines which company to use based on the subdomain in the link inputted by the user, so for example:

apple.myapplicationsnamehere.com

Should look at the companies in my database, and find out which one is called "apple", then separate all of the data by apples ID.

This works fine on the localhost (if you're wondering how this is possible, I used a redirect to my localhost that I found online - http://apple.lvh.me:3000/ )

However, this does not work on Cloud Foundry.

I have tried to use vmc's map function to create the Url: apple.myapplicationsnamehere.cloudfoundry.com, but this does not work, and simply appending a subdomain to my application doesn't work either.

Does anyone know of any way around this? Or perhaps I'm missing something? The database was seeded with caldecott already, so the companies certainly exist in the database.

You should be able to run a:

vmc map myapplicationnamehere apple.myapplicationsnamehere.com

vmc map myapplicationnamehere orange.myapplicationsnamehere.com

vmc map myapplicationnamehere pear.myapplicationsnamehere.com

Though i don't believe you can setup a wildcard match, so you'll need to run a vmc command each time a new company is added into your environment.

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