简体   繁体   English

在AWS Elasticbeanstalk上的Rails 3中设置子域

[英]Setting up subdomains in Rails 3 on AWS Elasticbeanstalk

My rails app has the following subdomains: my, admins, locations 我的Rails应用程序具有以下子域:我,管理员,位置

I have set up my routes file as follows: 我已经按照以下步骤设置了路由文件:

routes.rb routes.rb

match '/' => 'admins#index', :constraints => { :subdomain => "admins" }
match '/' => ‘users#index', :constraints => { :subdomain => "my" }
match '/' => ‘locations#index', :constraints => { :subdomain => “locations” }

Locally, this works fine…If I point to admins.lvh.me, or my.lvh.me, it points to the right page. 在本地,这可以正常工作……如果我指向admins.lvh.me或my.lvh.me,则指向正确的页面。

My issue is when I deploy it to AWS ElasticBeanstalk. 我的问题是将其部署到AWS ElasticBeanstalk时。 Elasticbeanstalk makes my app accessible at aws_assigned_name.elasticbeanstalk.com. Elasticbeanstalk使我的应用程序可通过aws_assigned_name.elasticbeanstalk.com进行访问。 So I added a CNAME to my DNS as follows: 因此,我将CNAME添加到DNS中,如下所示:

my.mydomain.com CNAME aws_assigned_name.elasticbeanstalk.com

Can I do this multiple times, one for each subdomain? 我可以多次执行一次,每个子域一次吗? So my DNS would look like: 所以我的DNS看起来像:

my.mydomain.com CNAME aws_eb_assigned_name.elasticbeanstalk.com
admins.mydomain.com CNAME aws_eb_assigned_name.elasticbeanstalk.com
locations.mydomain.com CNAME aws_eb_assigned_name.elasticbeanstalk.com

Or what is the generally accepted method to handle this? 或处理该问题的公认方法是什么?

You can add a wildcard CNAME. 您可以添加通配符CNAME。 This will redirect all your subdomains. 这将重定向您的所有子域。

*.mydomain.com CNAME aws_eb_assigned_name.elasticbeanstalk.com

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

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