Private bucket origin · Cloudflare R2

Serve images from a private Cloudflare R2 bucket

Use a private Cloudflare R2 bucket as your image CDN origin. Edge nodes sign fetches with R2's S3-compatible API (SigV4, region auto) and serve resized AVIF or WebP.

How it works

Cloudflare R2 speaks the S3 API on https://<account id>.r2.cloudflarestorage.com/<bucket>/ and charges no egress fees. Keeping the bucket private and giving the console an Object Read Only API token lets edge nodes fetch originals directly from R2, resize and re-encode them to AVIF or WebP, and cache them at the edge.

# Public delivery URL
https://a3f9c21b.zwcld.net/v1/products/sofa.jpg?w=800&f=auto&q=auto
# Signed fetch by the edge node
GET https://0123456789abcdef0123456789abcdef.r2.cloudflarestorage.com/my-images/products/sofa.jpg

Signing: AWS Signature Version 4 (HMAC-SHA256) for service s3 with region auto, against the account's r2.cloudflarestorage.com endpoint.

What the console asks for

Field What to give
Bucket The R2 bucket name, such as my-images.
Account Your 32-character hexadecimal Cloudflare account id, as shown in the R2 S3 endpoint URL.
Folder (optional) A key prefix inside the bucket, such as images/originals.
Access key id and secret An R2 API token with Object Read Only permission, scoped to the one bucket.

The secret is sealed at rest with the Data Protection key ring and never shown back in the console. Rotating credentials means entering a new key on the bucket row; edge nodes pick it up within a minute.

Setting it up, step by step

  1. In the Cloudflare dashboard, open R2 → Manage R2 API Tokens and create a token with Object Read Only permission limited to your image bucket.
  2. Copy the token's Access Key ID, Secret Access Key, and your 32-character account id from the S3 endpoint URL.
  3. In the ZawCloud console, open the Domains tab → Add a private bucket, choose Cloudflare R2, and enter the bucket, account id and keys.
  4. Point the account's origin (or one custom hostname's origin) at the bucket and request /v1/<object-key>?w=800&f=auto.

Details worth knowing

  • No R2 public bucket domain (r2.dev) or custom R2 domain is needed: nodes call the private r2.cloudflarestorage.com API endpoint directly.
  • Renditions are cached under an identity private to your bucket record (bucket://<id>/<key>), so two accounts naming the same bucket never share cached files.
  • Rotating an R2 token in the console takes effect on every edge node within a minute.

Connect your bucket

An account can configure up to 10 private buckets and point the account origin or individual custom hostnames at them.

Other private bucket origins: Amazon S3 & S3-compatible , Google Cloud Storage , Azure Blob Storage .