Reputation: 4271
I register my domains with DNSimple. My app is hosted on Heroku.
How can I arbitrarily route all subdomains to my Heroku app?
Example
No matter what the user types as the subdomain (always just 1 level deep) I want it routed to my heroku app. Ideally I don't want to define every single subdomain in Heroku or DNSimple... it should just direct everything.
Any and all subdomains are just routed to my app where I handle the logic of what to do with request.subdomain
method.
Will having these "foul" up what I am trying to do (below)
Thanks!
Upvotes: 1
Views: 1496
Reputation: 19249
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.
The Heroku documentation on Wildcard domains is pretty clear:
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. You just need to have your DNS point there. So, in your DNS—probably hosted at your registrar in your case—add your wildcard record:
*.example.com. CNAME example-1234.herokuapp.com
(or whatever Heroku tells you to put as CNAME)
Upvotes: 3