I switched from DNSimple to CloudFlare, and it works perfectly. Now my setup looks like this:

Record

Name

Target

CNAME

example.com

example.ghost.io

CNAME*

www

example.com

MX

example.com

aspmx.l.google.com

* Cloudflare doesn't seem to have URL or FORWARD records, so I've just added another CNAME for my www subdomain, which seems to be working fine.

When I switched my blog to a hosted Ghost Pro plan, I ran into some difficulty getting the proper DNS configuration. I'm not a smart man networking guru, so I figured there might be others who could benefit from what I learned.

What's so complicated?

A traditional DNS setup would involve an A record for your domain, which points to your hosting provider's IP address, and a series of MX records which point to your email provider. You can have A and MX records for the same domain name, like so:

Record

Name

Target

A

example.com

185.31.17.133

MX*

example.com

aspmx.l.google.com

* There would actually be several MX records, but for readability's sake, I've just left a single example here.

When requests come in for your domain name, they get filtered by what type of traffic they are. Email gets sent to your MX records, and requests for web pages get sent to your A record.

What About www?

The part of your domain after the www is called the "root" or "apex" domain. The www part is a subdomain, and is defined as a separate DNS record.

If you want to add www.example.com as an alias for your domain (meaning visitors can access your site both via example.com and www.example.com) then you add a CNAME record for the www subdomain, like so:

Record

Name

Target

A

example.com

185.31.17.133

CNAME

www

example.com

MX

example.com

aspmx.l.google.com

A CNAME record is like an A record, except it points to another domain name instead of an IP address.

If you wanted to redirect all visitors on www.example.com to example.com instead, you'll need to set up a forwarding record. Most DNS providers support this functionality, though they call it different things.

Record

Name

Target

A

example.com

185.31.17.133

URL or FORWARD

www

example.com

MX

example.com

aspmx.l.google.com

How does cloud hosting make this more complex?

Cloud hosting providers — like Heroku, AWS, or Ghost Pro — don't allow you to point A records at an IP address on their servers, because they want the ability to change your IP addresses for security or performance reasons. For this reason, cloud hosting providers tell you to create a CNAME record pointing to their server, like so:

Record

Name

Target

CNAME

example.com

example.ghost.io

URL or FORWARD

www

example.com

MX

example.com

aspmx.l.google.com

But there's a problem with this setup: The DNS specification doesn't allow any other records to coexist with a CNAME record. Since your MX records have to live on the root domain, some services will see a CNAME record on your root domain and ignore any further records you've defined, which means your email stops working!

To get around this, there are two options:

Subdomain Redirection

Use a DNS provider that supports CNAME-like functionality at the root domain

Subdomain Redirection

This is pretty simple: You move the CNAME record from your root domain to the www subdomain and then forward all visitors to the subdomain, like so:

Record

Name

Target

URL or FORWARD

example.com

www.example.com

CNAME

www

example.ghost.io

MX

example.com

aspmx.l.google.com

This avoids the CNAME conflict on your root domain, but the disadvantage to this approach is it forces all visitors to your site onto the rather pointless www subdomain. Personally, I found this distasteful, and went for option 2:

Use a DNS provider that supports CNAME-like functionality at the root domain

Some DNS providers have a way to get CNAME-like functionality for the root domain using a custom record type. Some examples include:

For each provider, the setup is similar — you set the ALIAS or ANAME record for your root domain to point to your hosting provider's address, like so:

Record

Name

Target

ALIAS or ANAME

example.com

example.ghost.io

URL or FORWARD

www

example.com

MX

example.com

aspmx.l.google.com

There's one small catch

For most people, that setup should work just fine. It's a common pattern in use on many sites around the world. However, when I set that up for my domain, all of a sudden my parents couldn't send any email to me.

They could receive email from me just fine, and I could receive email from everyone else. But if they tried to email me, it would bounce with the following error:

CNAME lookup failed temporarily. (#4.4.3)
I'm not going to try again; this message has been in the queue too long.

When I emailed my DNS provider about this, they explained that the problem is almost certainly with my parent's email provider — Juno.com — and there wasn't much we could do to fix the issue.

As far as I can tell, the DNS configuration is fine and should work well. As for the specific bounces from Juno, it's possible that they're using a version of qmail that is buggy. I found this thread which has an explanation in it, as well as another bit of information on the issue.

Sorry, I'm not sure if there's much else I can offer. Given the number of customers that use the ALIAS and MX record together, I find it really hard to believe that the issue is something that is affecting a broad number of customers.

I can't think of anything else we could do at this point, aside from contacting Juno directly and asking them if they have a solution (and politely suggesting they upgrade their mail systems).

So, in the end, that's where I left it. My www subdomain redirects to spaceninja.com, which is an ALIAS record to my Ghost blog, and my MX records are pointed to google. Everything is working perfectly — except I can't get email from my parents on my Spaceninja email. Now if I can just convince them to abandon Juno, everything will be perfect!