简体   繁体   English

将所有子域路由到我的Heroku Rails应用程序

[英]Route all subdomains to my Heroku Rails app

I register my domains with DNSimple. 我用DNSimple注册我的域名。 My app is hosted on Heroku. 我的应用程序托管在Heroku上。

How can I arbitrarily route all subdomains to my Heroku app? 如何随意将所有子域路由到我的Heroku应用程序?

Example

  • bluejays.cappedin.com bluejays.cappedin.com
  • redsox.cappedin.com redsox.cappedin.com
  • anything.cappedin.com anything.cappedin.com

No matter what the user types as the subdomain (always just 1 level deep) I want it routed to my heroku app. 无论用户输入什么类型的子域(总是只有1级),我希望它路由到我的heroku应用程序。 Ideally I don't want to define every single subdomain in Heroku or DNSimple... it should just direct everything. 理想情况下,我不想在Heroku或DNSimple中定义每个子域...它应该只指向一切。

Any and all subdomains are just routed to my app where I handle the logic of what to do with request.subdomain method. 任何和所有子域都只是路由到我的应用程序,在那里我处理了如何处理request.subdomain方法的逻辑。

Will having these "foul" up what I am trying to do (below) 将这些“犯规”提升到我想做的事情(下面) 在此输入图像描述

Thanks! 谢谢!

In DNS setups, there are usually two parts to the equation: (1) the sending side, which is the DNS server that will direct the traffic to the server, and (2) the receiving side, which is the server being sent the traffic to, that often needs to know on which domains to listen. 在DNS设置中,通常有两个部分:(1)发送方,即将流量引导到服务器的DNS服务器;(2)接收方,即发送流量的服务器通常需要知道要监听的域名。

The Heroku documentation on Wildcard domains is pretty clear: Wildcard域上的Heroku文档非常清楚:

Add a wildcard domain to your app as you would with any other domain, but use the * wildcard subdomain notation. 像对待任何其他域一样,将通配符域添加到您的应用程序,但使用*通配符子域表示法。

 $ heroku domains:add *.example.com Adding *.example.com to example... done 

The Heroku router is ready to receive your traffic. Heroku路由器已准备好接收您的流量。 You just need to have your DNS point there. 你只需要在那里拥有你的DNS点。 So, in your DNS—probably hosted at your registrar in your case—add your wildcard record : 因此,在您的DNS中 - 可能是您的注册商托管 - 添加您的通配符记录

*.example.com.  CNAME   example-1234.herokuapp.com

(or whatever Heroku tells you to put as CNAME) (或Heroku告诉你把它作为CNAME的任何东西)

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

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