Today I would like to talk about the CNAME record needed to use your own domain on Heroku.
On their documentation page, Heroku asks you to create a CNAME record pointing the subdomain to your app’s Heroku
Something similar to this:
Pretty easy right? Yes, only if you don't use any of the services 1&1 provide. In my case, I use also 1&1 to have a custom email address as explained earlier. In this case you have to do more that just creating the CNAME record.
On Wikipedia, you can find this:
- An alias defined in a CNAME record must have no other resource records of other types (MX, A, etc.).
-- Source: http://en.wikipedia.org/wiki/CNAME_record
But if you want to use the custom email address, you need a MX Record:
A mail exchanger record (MX record) is a type of resource record in the Domain Name System that specifies a mail server responsible for accepting email messages on behalf of a recipient's domain
-- Source: http://en.wikipedia.org/wiki/MX_record
One way I found to solve this issue was to use a third party DNS provider. In this article I will explain the steps using DNS Made Easy.
DNS Made Easy allows you to configure the CNAME records, MX records, A Records, ... very easily.
For the rest of the article, we will only focus on how to configure 1&1 and DNS Made Easy to have your website and your email working. But it is not the only functionality provided by both.
Here is my solution (We assume you have an account on 1&1, Heroku and DNSMadeEasy):
DNS Made Easy
Add your domain:
Configure your MX record as follow:
Configure your ANAME record:
We are done with DNS Made Easy.
To configure your 1&1 domain to point on your nameserver follow the instructions on this page: Use Your Own Name Server for a 1&1 Domain
On step 5, enter the first 4 nameservers you can find on your DNS Made Easy account. It should look like this:
- This Stackoverflow question (Heroku & DNS: Can
http://nakeddomain.comaim at my heroku app?), and particularly this answer.
- CNAME Is Out; Hello ANAME!
- What Is An ANAME Record?