0

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...

snowangel
  • 3,452
  • 3
  • 29
  • 72
  • When you say "redirects", do you mean you want the user to have the url `bobcat.com` showing while viewing the content of `https://bobcat.mysite.com`? Just trying to clarify. – veritas1 Oct 10 '12 at 13:50
  • Hi - ideally, yes. But I'd be happy enough for the address bar to say `https://bobcat.mysite.com` after the user typed in `http://bobcat.com`. – snowangel Oct 10 '12 at 13:52

2 Answers2

2

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.

Thomas Klemm
  • 10,678
  • 1
  • 51
  • 54
  • Thanks for that @thomas-klemm - but do you know how you redirect www.bobcat.com to subdomain.myapp.herokuapp.com, for that is what I want? At the moment I have a CNAME pointing to bobcat.mysite.com, but it only displays mysite.com. Thanks! – snowangel Oct 22 '12 at 11:54
  • Have you made your app recognize subdomains correctly? The settings there might be a little tricky for it to behave the same with the third-level bobcat.mysite.com and fourth-level bobcat.myapp.herokuapp.com. – Thomas Klemm Oct 22 '12 at 13:21
  • I have no idea, to be honest. The result of `heroku certs` is Endpoint: akita-randomnumber.herokussl.com Common name: *.bobcat.com, bobcat.com – snowangel Oct 22 '12 at 15:08
  • I meant internal recognition: There's a [`config.action_dispatch.tld_length`](http://guides.rubyonrails.org/configuring.html#configuring-action-dispatch) that allows `request.subdomain` to parse correctly. See this stackoverflow [question](http://stackoverflow.com/questions/7079586/rails-3-x-tld-length). Could it be that DNS settings are fine but your app parses subdomains incorrectly and thus displays the wrong site for the request? – Thomas Klemm Oct 23 '12 at 08:14
0

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
veritas1
  • 8,740
  • 6
  • 27
  • 37
  • 1
    Per [RFC1033](http://tools.ietf.org/html/rfc1033) CNAME cannot coexist with other records, which means that at the zone apex, since you need SOA and NS records, you can't have CNAME so this won't work. You can try that with BIND; it'll reject it. – Wil Tan Oct 15 '12 at 05:58