简体   繁体   English

Cloud Foundry Rails-基于子域的多租户

[英]Cloud Foundry Rails - Multi-tenancy based on subdomain

My rails application currently works as follows: 我的rails应用程序当前工作如下:

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. 数据库中的所有内容都属于这些公司之一,因此具有company_id属性以便将它们分开。

My application determines which company to use based on the subdomain in the link inputted by the user, so for example: 我的应用程序根据用户输入的链接中的子域来确定使用哪个公司,例如:

apple.myapplicationsnamehere.com 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. 应该查看我数据库中的公司,找出哪个叫“ apple”,然后按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/ ) 这在localhost上运行良好(如果您想知道这是怎么回事,我使用了重定向到我在网上找到的localhost的方法-http: //apple.lvh.me:3000/

However, this does not work on Cloud Foundry. 但是,这在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. 我尝试使用vmc的map函数创建Url:apple.myapplicationsnamehere.cloudfoundry.com,但这不起作用,并且仅将子域附加到我的应用程序中也不起作用。

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. 该数据库已经使用caldecott进行了播种,因此数据库中肯定存在公司。

You should be able to run a: 您应该能够运行:

vmc map myapplicationnamehere apple.myapplicationsnamehere.com vmc映射myapplicationnamehere apple.myapplicationsnamehere.com

vmc map myapplicationnamehere orange.myapplicationsnamehere.com vmc映射myapplicationnamehere orange.myapplicationsnamehere.com

vmc map myapplicationnamehere pear.myapplicationsnamehere.com vmc映射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. 尽管我不相信您可以设置通配符匹配,所以每次将新公司添加到您的环境中时,都需要运行vmc命令。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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