12

My .io domain works for www.domain.io, but not for the domain.io version. Below are each of the versions and revisions I have tried with ample time between each. I al

@ 10800 IN A 174.129.212.2
@ 10800 IN A 75.101.145.87
@ 10800 IN A 75.101.163.44
blog 10800 IN CNAME blogs.vip.gandi.net.
imap 10800 IN CNAME access.mail.gandi.net.
pop 10800 IN CNAME access.mail.gandi.net.
smtp 10800 IN CNAME relay.mail.gandi.net.
webmail 10800 IN CNAME webmail.gandi.net.
www 10800 IN CNAME domain.herokuapp.com
@ 10800 IN MX 50 fb.mail.gandi.net.
@ 10800 IN MX 10 spool.mail.gandi.net.

@ 10800 IN A 174.129.212.2
@ 10800 IN A 75.101.145.87
@ 10800 IN A 75.101.163.44
www 10800 IN CNAME domain.herokuapp.com

@ 10800 IN A 174.129.212.2
@ 10800 IN A 75.101.145.87
@ 10800 IN A 75.101.163.44
www 10800 IN CNAME domain.herokuapp.com.

removed @ lines because of Gandi and Heroku set up issue

www 10800 IN CNAME domain.herokuapp.com.

From reading other answers like How to setup DNS for an apex domain (no www) pointing to a Heroku app?, it seems that it best to redirect from the root domain to the one with www. Any other way?

Also are the lines for gandi.net are necessary?

Community
  • 1
  • 1
Patrick
  • 1,410
  • 2
  • 19
  • 37

3 Answers3

18

it seems that it best to redirect from the root domain to the one with www. Any other way?

As of right now, no. Unfortunately, ALIAS records are not used by Gandi, and A records are not available for use with Heroku because Heroku does not use fixed IP addresses.

The record type that both Heroku and Gandi recognize is the CNAME record, which can not be used for bare domains. Or, at least, shouldn't be used for bare domains. See https://superuser.com/questions/264913/cant-set-example-com-as-a-cname-record.

And for anyone lost, looking for how the heck to implement this, here's my cheat sheet for the work-around.

Step 1: In Gandi, set DNS zone file.

Name  Type     Value

@     A        217.70.184.38  # Gandi's server
*     CNAME    my-app.herokuapp.com.  # trailing . is required
www   CNAME    my-app.herokuapp.com.  # trailing . is required

Step 2: In Gandi, set web forwarding for the domain.

The type of forwarding will be 'direct (permanent)', leave the subdomain blank, and set the forwarding address as www.my-custom-domain.com.

Step 3: In Heroku, set Heroku custom domains.

Domain Name                 DNS Target

*.my-custom-domain.com      my-app.herokuapp.com
my-custom-domain.com        my-app.herokuapp.com
www.my-custom-domain.com    my-app.herokuapp.com
Community
  • 1
  • 1
SarahJaine
  • 181
  • 1
  • 3
  • 1
    I think the Heroku part of this is out of date.e.g. in Step 3: If you do `heroku domains:add my-custom-domain.com` then the DNS Target is set as `my-custom-domain.com.herokudns.com` and adding `www.my-custom-domain.com` has a target of `www.my-custom-domain.com.herokudns.com`. So, the targets use `herokudns` instead of `herokuapp`, but I'm also not sure how to give all the custom domains the same target. – Phil Gyford Aug 25 '17 at 10:24
  • This won't work if your domain uses https. If you try to open your website with https without the www https://example.com/ it won't rediret! `curl -I https://example.com/ curl: (7) Failed to connect to example.com port 443: No route to host` – sys0dm1n Nov 10 '17 at 12:12
  • yeah, I have this exact same problem with https ... https://github.com/AgileVentures/WebsiteOne/issues/2585 – Sam Joseph Aug 24 '18 at 00:59
  • 1
    This is out of date. Gandi.net now supports ALIAS – mas May 29 '19 at 20:49
2

it seems that it best to redirect from the root domain to the one with www. Any other way?

Some DNS providers have an ALIAS record type which synthesizes the A records on the naked domain at request time. That and the URL record are the only options, since Heroku has essentially removed the use of fixed IP addresses with their current stack.

Also are the lines for gandi.net are necessary?

If you do not use Gandi for email or your blog, then you can remove all of the gandi lines. The MX records tell SMTP servers to use Gandi's mail exchanges to try to deliver mail, and the CNAME records are simply ways to access those Gandi services with your custom domain.

Anthony Eden
  • 86
  • 1
  • 6
0

As someone already mentioned, gandi.net now supports ALIAS so it could be done simpler, like this:

@ 10800 IN ALIAS stormy-squirrel-xe57il0fhyuauzta3noapg1h.herokudns.com.

And in the heroku, you must add only the bare domain and use the given dns

(such as: stormy-squirrel-xe57il0fhyuauzta3noapg1h.herokudns.com.)

GarryOne
  • 1,430
  • 17
  • 21