Skip to content

phricardo/EdgeBucket

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

MinIO Edge Proxy

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.


🚀 Features

  • 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.


🧠 When to Use

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.png instead 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.


⚙️ How It Works

  1. Receives a request (e.g., https://cdn.example.com/image.jpg).
  2. Looks up the cached response in Cloudflare’s edge cache.
  3. If not cached:
    • Rewrites the request to MinIO (https://your-minio-host/bucket-prefix/image.jpg).
    • Fetches the file.
    • Caches it for future requests.
  4. If MinIO responds with XML error, shows a custom HTML error page.

🛠️ Environment Variables

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

📦 Deployment (with Wrangler)

npm install -g wrangler

# Preview locally
wrangler dev

# Publish to Cloudflare
wrangler publish

About

Cloudflare Worker that proxies and caches MinIO bucket content at the edge, with custom error handling and clean URLs.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors