DEV Community

Wilson McCoubrey
Wilson McCoubrey

Posted on

Setup Custom Domain for S3 Static Website with Cloudflare CDN


This post briefly describes a little bit of what I learned when looking to setup a custom domain and CDN for a static website hosted on S3.


Bucket name needs to match custom domain. E.g. to setup a custom domain of, bucket name must be


This quick guide assumes you have:

  • A static website running successfully inside a bucket in S3, accessible via the bucket url e.g. http://<bucket name>.s3-website-<region>
  • A domain setup in cloudflare and nameservers setup


Set bucket name correctly

When setting up your bucket, your bucket name must match the custom domain which you want to serve the site from. For example, to setup a custom domain of, bucket name must be I originally made this mistake and received 'NoSuchBucketException' in the browser after setting up my domain.

Add CNAME Record to Cloudflare

Enable SSL (Optional, but recommended)

Discussion (0)