This project is a Cloudflare Worker that acts as an edge proxy and caching layer for a MinIO bucket. It rewrites and fetches files from a MinIO backend, caches them on Cloudflare's edge, and provides friendly error responses — all while hiding the internal structure of your storage service.
-
✅ Edge Caching
Automatically caches static assets (images, videos, etc.) at Cloudflare's edge nodes with customizable TTL. -
🔐 Backend Protection
Hides your real MinIO endpoint from the public by acting as a controlled gateway. -
🔁 Path Rewriting
Dynamically rewrites incoming requests to match the path and hostname structure required by MinIO. -
💥 Error Handling
Transforms raw XML error responses (from MinIO) into clean, human-friendly HTML messages, including a request ID. -
⚙️ Custom Logic
Easy to expand with token-based access, header validation, or logging.
Use this Worker if:
- You want fine-grained control over caching of files stored in MinIO.
- You prefer to serve pretty URLs like
https://cdn.example.com/logo.pnginstead of long signed URLs. - You want to hide or protect your MinIO origin behind Cloudflare.
- You want to customize error pages or do header manipulation.
- You're not just proxying — you need logic, caching, or transformations.
If you only need basic file delivery and already have Cloudflare proxying your MinIO endpoint directly, this might be overkill.
- Receives a request (e.g.,
https://cdn.example.com/image.jpg). - Looks up the cached response in Cloudflare’s edge cache.
- If not cached:
- Rewrites the request to MinIO (
https://your-minio-host/bucket-prefix/image.jpg). - Fetches the file.
- Caches it for future requests.
- Rewrites the request to MinIO (
- If MinIO responds with XML error, shows a custom HTML error page.
Configure these via your wrangler.toml or the Cloudflare dashboard:
| Variable | Description |
|---|---|
HOST_ORIGIN |
Hostname of your MinIO server |
BUCKET_PREFIX |
Prefix or bucket name in the path |
npm install -g wrangler
# Preview locally
wrangler dev
# Publish to Cloudflare
wrangler publish