This is something that I've seen discussed in some other places, but this issue in particular hasn't been spelled out exactly as not being possible.
I want to point an apex domain to a heroku app (example.com
to example.herokuapp.com
)
CNAME doesn't seem to be possible, because they are not allowed at the apex level (sub domains are fine).
ALIAS records seem to be an option, even though I don't fully understand them, or if they are standard. We use AWS Route53 as our DNS provider, but ALIAS records only seem to be possible to use for specific Amazon services (s3 website, load balancer, ..)
So is it possible to point an apex domain to a Heroku app? Is my only other option to use another DNS provider?
Thanks
EDIT: I'm aware that I can CNAME www.example.com
to example.herokuapp.com
, and then redirect from example.com
to www.example.com
using an ALIAS record, and an S3 site that redirects. But what we want is the exact opposite, we want the browser to show example.com
.
Alias record are not an actual DNS record type -- they are pointers to other records within Route 53, so the target of an Alias record can only be an S3 bucket, an Elastic Load Balancer, a CloudFront distribution, or another record of the same type (e.g., an
A
record) within your hosted zone. Route 53 uses its internal database to find the target and return a standard DNS response.So it is not directly possible to point an Alias to an external destination.
If you really want to point an Alias at an external destination, it is indirectly possible using CloudFront, because CloudFront accepts a hostname (example.herokuapp.com) as the name of the Origin server where requests will be forwarded. It also allows you to use an SSL certificate generated by Amazon Certificate Manager, and to selectively route different path patterns to different destinations (such as routing
/images/*
to an S3 bucket, for example). The caching behavior of CloudFront can be customized or disabled, if you don't want it.This will, of course, incur usage charges for requests and bandwidth, but provides some additional capabilities that might be worth it, including relieving load on your heroku service if caching is something you could benefit from.
There are, however, valid reasons for using the www hostname rather than the bare domain, and configuring the bare domain to redirect incoming requests to www, which can be done in a number of different ways.