I bought a domain name at domain.com, and tried to link it to my heroku app. Heroku provided me a DNS target, and I have put it through to my "DNS record" config in domain.com.
However when I try to generate automatic SSL certificate for my app, it still fails and returns me "CDN not returning HTTP challenge". I referred to this documentation, it says the reason for this error is that I haven't pointed the DNS to the one provided by Heroku DNS target. But I have already done it
Is there anything I misunderstood, or do I basically have to wait for a few days for it?
Under name just list it as www.your_site.com, heroku says that it will forward www.example.com to example.com.
In this case, as long as you have www.example.com set up, example.com
isn't needed as users can reach your site via www.example.com and to
set up www.example.com you need to use CNAME Records which all DNS
Providers allow you to set.
I have a test app hosted at heroku for free, for which I bought a domain example.com that is managed through cloudflare, hopefully, to add free ssl after too.
The app is running ok at example.herokuapp.com. In heroku's dashboard I added the domains
example.com that gave me a random-url.heroku.com dns target in return
www.example.com gave me a random-url2.heroku.com in return
I then added two CNAME registries on Cloudflare
CNAME example.com pointing to random-url.heroku.com
CNAME www.example.com pointing to random-url2.heroku.com
SSL is off in cloudflare to test it out.
Opening example.com in chrome says This page isn’t working, redirected you too many times.
I can't configure my DNS in order to redirect my root domain to www.domain for a Heroku app.
I'm using Vultr's DNS. The problem is Heroku does not provide IP address so I can't add an A record, nor a CNAM record to redirect root to www (source):
DNS A-records require that an IP address be hard-coded into your
application’s DNS configuration. This prevents your infrastructure
provider from assigning your app a new IP address on your behalf when
adverse conditions arise and can have a serious impact to your app’s
uptime.
A CNAME record does not require hard-coded IP addresses and allows
Heroku to manage the set of IPs associated with your domain. However,
CNAME records are not available at the zone apex and can’t be used to
configure root domains.
Here is my DNS configuration:
Thus, the SSL certificate fails in Heroku:
My question is: how can I easily redirect the root domain of my Heroku app to www.domain.com?
Thanks.
ping with the DNS target you have got from Heroku. you will get the IP for that. Use that as Dns targe in vultr. worked for me.
example:
➜ ~ ping botletter.com.herokudns.com
PING botletter.com.herokudns.com (3.212.117.40): 56 data bytes
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
Here use 3.212.117.40 IP in vultr DNS target
I already added a custom domain to my Heroku app and it works with www.domain.com.
I need to know how to set up the domain without www to resolve to the app, too.
Here are my current DNS settings:
$TTL 86400
# IN SOA ns1.first-ns.de. postmaster.robot.first-ns.de. (
2013041500 ; serial
14400 ; refresh
1800 ; retry
604800 ; expire
86400 ) ; minimum
# IN NS robotns3.second-ns.com.
# IN NS robotns2.second-ns.de.
# IN NS ns1.first-ns.de.
# IN A 88.198.38.XXX
localhost IN A 127.0.0.1
mail IN A 88.198.38.XXX
ftp IN CNAME www
imap IN CNAME www
loopback IN CNAME localhost
pop IN CNAME www
relay IN CNAME www
smtp IN CNAME www
www IN CNAME appname.herokuapp.com.
# IN MX 10 mail
What are the correct settings to use so that both example.com and www.example.com would point correctly to my Heroku app?
(Note: root, base, apex domains are all the same thing. Using interchangeably for google-foo.)
Traditionally, to point your apex domain you'd use an A record pointing to your server's IP. This solution doesn't scale and isn't viable for a cloud platform like Heroku, where multiple and frequently changing backends are responsible for responding to requests.
For subdomains (like www.example.com) you can use CNAME records pointing to your-app-name.herokuapp.com. From there on, Heroku manages the dynamic A records behind your-app-name.herokuapp.com so that they're always up-to-date. Unfortunately, the DNS specification does not allow CNAME records on the zone apex (the base domain). (For example, MX records would break as the CNAME would be followed to its target first.)
Back to root domains, the simple and generic solution is to not use them at all. As a fallback measure, some DNS providers offer to setup an HTTP redirect for you. In that case, set it up so that example.com is an HTTP redirect to www.example.com.
Some DNS providers have come forward with custom solutions that allow CNAME-like behavior on the zone apex. To my knowledge, we have DNSimple's ALIAS record and DNS Made Easy's ANAME record; both behave similarly.
Using those, you could setup your records as (using zonefile notation, even tho you'll probably do this on their web user interface):
# IN ALIAS your-app-name.herokuapp.com.
www IN CNAME your-app-name.herokuapp.com.
Remember # here is a shorthand for the root domain (example.com). Also mind you that the trailing dots are important, both in zonefiles, and some web user interfaces.
See also:
Doing DNS right with Heroku
Avoiding Naked Domains and DNS A-records
Remarks:
Amazon's Route 53 also has an ALIAS record type, but it's somewhat limited, in that it only works to point within AWS. At the moment I would not recommend using this for a Heroku setup.
Some people confuse DNS providers with domain name registrars, as there's a bit of overlap with companies offering both. Mind you that to switch your DNS over to one of the aforementioned providers, you only need to update your nameserver records with your current domain registrar. You do not need to transfer your domain registration.
To point your apex/root/naked domain at a Heroku-hosted application, you'll need to use a DNS provider who supports CNAME-like records (often referred to as ALIAS or ANAME records). Currently Heroku recommends:
ALIAS at DNSimple
ANAME at DNS Made Easy
ANAME at easyDNS
ALIAS at PointDNS
CNAME at CloudFlare
Whichever of those you choose, your record will look like the following:
Record: ALIAS or ANAME
Name: empty or #
Target: example.com.herokudns.com.
That's all you need.
However, it's not good for SEO to have both the www version and non-www version resolve. One should point to the other as the canonical URL. How you decide to do that depends on if you're using HTTPS or not. And if you're not, you probably should be as Heroku now handles SSL certificates for you automatically and for free for all applications running on paid dynos.
If you're not using HTTPS, you can just set up a 301 Redirect record with most DNS providers pointing name www to http://example.com.
If you are using HTTPS, you'll most likely need to handle the redirection at the application level. If you want to know why, check out these short and long explanations but basically since your DNS provider or other URL forwarding service doesn't have, and shouldn't have, your SSL certificate and private key, they can't respond to HTTPS requests for your domain.
To handle the redirects at the application level, you'll need to:
Add both your apex and www host names to the Heroku application (heroku domains:add example.com and heroku domains:add www.example.com)
Set up your SSL certificates
Point your apex domain record at Heroku using an ALIAS or ANAME record as described above
Add a CNAME record with name www pointing to www.example.com.herokudns.com.
And then in your application, 301 redirect any www requests to the non-www URL (here's an example of how to do it in Django)
Also in your application, you should probably redirect any HTTP requests to HTTPS (for example, in Django set SECURE_SSL_REDIRECT to True)
Check out this post from DNSimple for more.
I am now using Google Apps (for Email) and Heroku as web server. I am using Google Apps 301 Permanent Redirect feature to redirect the naked domain to WWW.your_domain.com
You can find the step-by-step instructions here
https://stackoverflow.com/a/20115583/1440255
You are not allowed to have a CNAME record for the domain, as the CNAME is an aliasing feature that covers all data types (regardless of whether the client looks for MX, NS or SOA records). CNAMEs also always refer to a new name, not an ip-address, so there are actually two errors in the single line
# IN CNAME 88.198.38.XXX
Changing that CNAME to an A record should make it work, provided the ip-address you use is the correct one for your Heroku app.
The only correct way in DNS to make a simple domain.com name work in the browser, is to point the domain to an IP-adress with an A record.
I've setup a SSL certificate w/ the common name, etc. as 'www.biglikeco.com'. I have set 1 cname in my dns to goto the main Heroku app area - what should the other CNAME record be? I I'm trying to get SSL working on 'www.biglikeco.com' also - is this possible (e.g. https://www.biglikeco.com as well as http://www.biglikeco.com) ?
Thanks.
SSL certificates are usually associated with an IP address, not a DNS record.
You need to associate the SSL certificate with your IP on the configuration of your web server. If you don't have an IP address dedicated to hosting the secure version of your site, you can rely upon Server Name Indication. Server Name Indication is an extension to the SSL certificate authentication process, such that the domain name AND the IP address are sent to your web server. DNS (and CNAME records) are not involved in this process, other than the initial name resolution.
Update:
You don't need a second IP address to host a secure version of your site. You can configure your web server to respond to HTTP and HTTPS separately. However, the SSL certificate is still strongly associated with your IP address. It cannot be redirected with a CNAME in DNS.