问题
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?
回答1:
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
回答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.
回答3:
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.
)
来源:https://stackoverflow.com/questions/22854091/gandi-net-and-heroku-domain-routing