Heroku subdomain DNS
-
06-07-2021 - |
Pergunta
I have a Rails app with a custom domain and wildcard subdomains hosted on Heroku (Cedar). Let's call it https://mysite.com.
If a user goes to, for instance, https://bobcat.mysite.com, the Rails app is configured to serve only the data relating to bobcat's account.
bobcat.com is registered with a domain-names company - nothing to do with Heroku. I want to change the DNS settings so that bobcat.com redirects to https://bobcat.mysite.com. What CNAME settings do I use? What do I do on my Heroku account.
Forgive this question which could probably be answered by sufficient googling, but I can't get this wrong...
Solução
The Heroku docs on custom domains holds all info for you.
It's especially important that you set entries for both bobcat.com
and www.bobcat.com
, which are in terms of DNS two seperate entries.
For Heroku, the www.bobcat.com
is handled by a CNAME to myapp.herokuapp.com
(on the cedar stack).
For "Naked domains" such as bobcat.com
however no cname can be specified (tue to limitations in the DNS Specifications) so you have two options:
1) Point bobcat.com
A-Records to the IP-Adresses specified in the docs above.
OR
2) Redirect bobcat.com
to www.bobcat.com
using wwwizer's free service. It's as easy as pointing bobcat.com
A-Records to 174.129.25.170
. I use this approach in a couple of my projects.
Outras dicas
So I believe, in the DNS settings for the domain name bobcat.com
, you need to create a new CNAME
record.
So it would be:
Hostname: bobcat.com
Type: CNAME
Destination CNAME: https://bobcat.mysite.com