Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails - Configuring DNS to host with Heroku (123-reg)

I am trying to figure out how to publish my app on heroku. My DNS is with 123-reg. 123-reg does not provide any support for heroku deployment and vice versa.

I have previously asked this question (voted down and mocked in the comments) Rails, Heroku - configuring 123-reg domain for heroku

I'm asking again in the hope of finding some substantive help on how to get this working.

Currently, when I try to render the page using my custom domain name, I get an error that says:

This site can’t be reached www.mydomainname.com ’s server DNS address could not be found. Try running Network Diagnostics.

DNS_PROBE_FINISHED_NXDOMAIN

When I try the following in the terminal, I get the responses noted below:

host www.mycustomdomainname.com 

Host www.mycustomdomainname.com not found: 3(NXDOMAIN)

host https://www.mycustomdomainname.com

Host https://www.mycustomdomainname.com not found: 2(SERVFAIL)

dig www.mycustomdomainname.com cname +short

myherokualias.herokudns.com

heroku domains returns the heroku alias both with and without the www prefix.

In my DNS, I have a CNAME record with:

DNS ENTRY TYPE PRIORITY TTL DESTINATION/TARGET www CNAME mycustomdomainname.herokudns.com.

Apart from that I have MX and TXT records for my email account.

Can anyone see what I need to do to get the page to render using my custom domain name?

When I try:

curl -vI https://www.mycustomdomainname.com * Rebuilt URL to: https://www.mycustomdomainname.com/ * Could not resolve host: www.mycustomdomainname.com * Closing connection 0 curl: (6) Could not resolve host: www.mycustomdomainname.com

I'm lost for things to try to get this working

HEROKU SETTINGS

I can see from inspecting my heroku Production Check, that I have the following issues:

FAILED DNS configuration
Your DNS is not configured correctly. Your domain "mycustomdomain.com"'s ALIAS or ANAME record should point to ancient-water-74339.herokuapp.com.

However, it also says:

PASSED Heroku SSL

The Heroku SSL instructions say:

Change your DNS for all domains on your app
Verify your DNS settings by running dig www.yourdomainname.com cname +short. If it returns www.yourdomainname.com.herokudns.com then you have set it up correctly. If you are using an ALIAS or ANAME record, you can verify that based on the DNS provider. For instance, DNSimple will return a TXT record showing how your domain’s ALIAS is set-up.
You should note that it may take up to 24 hours before your DNS is fully propagated globally.

To me, that means I'm supposed to replace the reference to 'herokuapp' with a reference to 'herokudns'. Also, I am reading these instructions to require that I replace 'ancient-water-74339' with a 'mycustomdomainname'.

I have done this (as I understand the instructions) so that the CNAME on my DNS now points to 'mycustomdomainname'.herokudns.com.

The heroku production check says that this is incorrect. Am I supposed to have 2 CNAME records (one using the heroku alias.herokuapp) and another using 'mycustomdomainname'.herokudns?

I tried to use the LetsEncrypt_plugin gem for rails. I cannot verify whether there is an error in that config because that gem does not provide support for heroku.

Can anyone see what I'm supposed to do to get out of this configuration hell?

The heroku production check instructions for DNS with SSL give instructions to provision an SSL Endpoint. The SSL Endpoint instructions say they are only for legacy clients (I don't know what a legacy client is), but that page suggests using the Heroku SSL instead. Those instructions say to use 'herokudns.com' on the end of the app name.

I can't seem to get any combination of these instructions to work.

like image 612
Mel Avatar asked Oct 19 '16 22:10

Mel


2 Answers

Checklist

  1. On your DNS provider make sure your CNAME record is properly set:

    Host: *
    Points To: yourapp.herokussl.com
    

    How to add a CNAME record in 123-reg

  2. On Heroku go to 'Resources' and make sure you have the SSL add-on installed.

  3. On Heroku go to 'Settings/Domains and certificates' and make sure you have your custom domains correctly set:

    Domain Name: *.yourdomain.com
    DNS Target: yourapp.herokussl.com
    

    Please note the url on herokuapp.com and herokussl.com may differ. If you are using an SSL certificate you'll have to use the latter.

Gotchas

  • Using the heroku toolbelt make sure your SSL certificate is still trusted

    heroku certs:info --app yourapp
    
  • Your registrar and your DNS provider may differ, this may lead you to be editing your CNAME records on the incorrect place.

    To make sure you are at the right spot perform a whois on your domain:

    whois yourdomain.com | grep 'Name Server'
    

    If your domain is actually pointing to 123-reg, the output should be:

    Name Server: ns1-123-reg.co.uk
    Name Server: ns2-123-reg.co.uk
    

    If the output is something else, then you probably should be setting your CNAME records elsewhere.

Hope this helps <3

like image 71
rebagliatte Avatar answered Nov 14 '22 22:11

rebagliatte


After pointing your domain to Heroku app on your Heroku dashboard, go to settings tab and scroll down to custom domain. There click on ADD DOMAIN and add your custom domain.

like image 29
Parry Avatar answered Nov 14 '22 22:11

Parry