AWS S3 Bucket working with Cloudflare, a Short HowTo

Home » Notes » AWS S3 Bucket working with Cloudflare, a Short HowTo

First off, I much prefer Cloudflare’s R2 over Amazon’s S3 for a slew of reasons, but I found myself in a place where I needed to offload about 80Gb to AWS S3 bucket to be served under a subdomain, proxied by Cloudflare.

I ran into a problem where I could not get a properly configured AWS S3 bucket to serve its content when added to the Cloudflare proxied domain via a CNAME record. Unfortunately, all I got were 403 and 522 error messages. I’ve lost count over how many different ways I have double-checked existing setups with the one I was setting up, but not luck.

Wasted three hours debugging, reading through all the documentation and information in the forums until I figured out what the solution was. This note is nothing more than me writing this down for future Remkus and anyone else who stumbles upon this note.


  1. We’re assuming you’re familiar with how to set up an AWS S3 Bucket to serve content.
  2. We’re als assuming you understand basic DNS setup of CNAME’s and the like
  3. Lastly, we’re also assuming you already have your site working within Cloudflare’s environment.

Time needed: 1 minute

Configure S3 Bucket in Cloudflare’s DNS properly

  1. Copy the S3 bucket public URL

    Login into your S3 Console, find your bucket, and look at the bottom of the Properties tag. Right under the Static Website Hosting section you’ll find the bucket website endpoint. It will look something like this:

  2. Change bucket website endpoint

    The AWS endpoint documentation mentions sort of offhand that you may need to change this bucket website endpoint. And in my case, that’s what I needed to do.
    but this did work:
    All that was needed was to remove the -website part of the URL.

  3. Add adjusted bucket website endpoint as CNAME in Cloudflare

    Copy and paste adjusted website endpoint URL and paste it in the Target input field like so:

  4. Make sure you turn on Proxy

    As can be seen in the above screenshot, you’ll need to make sure Cloudflare is proxying that S3 bucket for it all to work as intended.

    Once you’ve done that, hit Save and all will be well.

Hope you don’t have to waste another three hours comparing every single setting in both AWS and Cloudflare 5 times over. Happy serving!

First name
This field is for validation purposes and should be left unchanged.

Automatically sent to your inbox, just like 🪄 

Leave a Reply

Your email address will not be published. Required fields are marked *