Help please with fixing s3 bucket url to cloudflare

Hi,

I had previously had my old website setup with Cloudflare. It was also running an amazon aws s3 bucket. The URL from the bucket was originally coming back as a very long url. And i can’t remember how we fixed it. We managed to somehow create a shorter, better url. Can someone please explain to me, in non tech savvy terms how i do it?

Ive tried adding CNAME to Cloudflare DNS. but its saying error i must be doing something wrong somewhere. Please help

Thanks in advance.

1 Like

Hi,

What is the error that you get?

This might be related to the headers and you could tray the following.

Overriding host headers without an Enterprise plan requires implementing a Cloudflare Worker to rewrite the origin host header to your needs. Specifically you will want to take a look at Static Site Hosting for a recipe you can cater towards your use case.

You can follow this article Fetching object storage assets through the Cloudflare CDN using a Cloudflare Worker, for specific directions.

Essentially you will want to:

  1. Create a subdomain in your DNS records that points to your 3rd party origin (img, cdn, etc).
    For example:
Type: CNAME
Name: cdn
Value: 3rd party origin
  1. Use the Static Site Hosting worker, remember to change the fetch at the bottom to your 3rd party origin.
  2. Create a Route for your worker to be available on the subdomain you just created. ex: cdn.example.com/*
  3. Change any HTML references for the 3rd party to cdn.example.com

Hi Salvador,

Thank you for the response, really appreciated.

I’ve managed to get everything working. But i’m still struggling with the bucket S3 URL. As its way too long so needs shortening. When upload them.

I’ve followed guides that say similar to you, that i need to create a CNAME. With my bucket name: media.insomniacs.party then add the amazon s3 url after it.

Ive done that, but when i upload an image now, it’s not showing at all.

So I’m obviously adding the CNAME wrong. I’ve added:

CNAME
cdn
media.insomniacs.party.s3.eu‑west‑2.amazonaws.com

But that wont work.

The actual url to the upload is: https://s3.eu‑west‑2.amazonaws.com/media.insomniacs.party/wp‑content/uploads/2022/04/04001251/
(That’s an example upload, hence why I’ve added to this description)

The actual url has my bucket name at the end. Ive edited the wordpress plugin to Cloudflare, but when i upload there is no image.
The plugin then allows me to add any url as CDN. Which ive chosen media.insomniacs.party

So when i now upload an image it says media.insomniacs.party/imagename
But it’s not showing the image.

I’m so confused at the moment as i know it’s something small that im doing wrong. Likely the CNAME.

Thanks again for your reaponse its hugely appreciated.

Also, when i create a subdomain, do i do that via Cloudflare? Or do i have to use namecheap as thats who my domain is with. I’m going to transfer my domain to Cloudflare. Along with everything else. I just need to get the url right with being brand new site as want to at least get it looking decent in the meantime.

Regards and thanks again.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.