Cloudflare
How you use Cloudflare depends on where your media is stored. Your domain must be on Cloudflare in both cases.
Cloudflare changes its dashboard from time to time. If a screen looks different, follow the linked Cloudflare guide for that step.
With Cloudflare R2 storage
This is the simplest setup.
- Open your bucket in the Cloudflare dashboard and go to Settings → Custom Domains → Connect Domain.
- Enter a subdomain such as
media.example.com. Cloudflare adds the DNS record for you. - In Media Cloud Sync, go to Settings and click Change on the Delivery card.
- Choose Cloudflare R2, enter the domain under Use Custom Domain Name (CNAME), and click Save.
- Click Recheck on the Delivery card.
A custom domain goes through Cloudflare’s cache. The r2.dev address doesn’t, so it has no cache to purge. See Cloudflare’s public buckets guide and R2 cache guide.
Note that by default Cloudflare only caches certain file types. Set up a Cache Rule if you want every file cached.
With other storage
To put Cloudflare in front of a bucket such as Amazon S3:
- Create a proxied DNS record for your subdomain, such as
media.example.com, pointing to your bucket’s address. - Requests must reach the right bucket, because storage providers use the host name to find it. Cloudflare recommends Cloud Connector for object storage. On Amazon S3, the alternative is a bucket named the same as your subdomain. See Cloudflare’s notes on S3 DNS records.
- In Media Cloud Sync, go to Settings and click Change on the Delivery card.
- Choose Cloudflare CDN, enter the domain under Use Custom Domain Name (CNAME), and click Save.
- Click Recheck on the Delivery card.
Under Cloudflare’s Full (Strict) SSL mode, bucket names can’t contain dots.
Clear stale files (optional) PRO
Connect CDN Cache Purge with your Zone ID and an API token with the Zone → Cache Purge permission. This matters on Cloudflare, where a deleted or replaced file can stay available until its cached copy is purged or expires.
Warning: On most Cloudflare plans, Purge everything clears the whole zone, including your site’s own cached pages.
Private Media
Private Media PRO isn’t available with Cloudflare CDN or Cloudflare R2.