Rev up your Caddy v2 server with the ability to finely control the bandwidth of your HTTP responses. Perfectly designed for CDN use-cases, this is not just another plugin — it's a key component of our soon-to-launch Media Edge software, meticulously crafted from scratch! 🛠
🔗 Dive into Caddy's magic on their GitHub.
Plug into the full power of Caddy by integrating our plugin. Let's get started:
- Grab xcaddy:
go get -u github.com/caddyserver/xcaddy/cmd/xcaddy
- Build Caddy with our bandwidth plugin:
xcaddy build --with github.com/mediafoundation/caddy-bandwidth
🎉 Voilà! You've got a caddy
binary, now supercharged with our plugin.
Eager to throttle bandwidth? Use the bandwidth
directive in your Caddyfile to set the max bytes-per-second:
localhost
route /myroute {
bandwidth {
limit 100000
}
}
Designed with CDN use-cases in mind, you can add bandwidth limits dynamically based on headers or other conditions:
{
order bandwidth before header
}
header Server "MediaEdge vX.Y.Z"
reverse_proxy http://localhost:8080 {
@hasBandwidthLimit header X-Bandwidth-Limit Yes
handle_response @hasBandwidthLimit {
bandwidth {
limit 50000
}
}
}
order bandwidth before header
: Place the bandwidth module before the header module in the processing order.
This allows you to have fine-grained control over bandwidth limits on a per-request basis!
Our plugin adheres to standard Go conventions, featuring a Middleware
struct that uses the caddyhttp.MiddlewareHandler
interface. The limitedResponseWriter
is meticulously designed to limit bandwidth.
💡 Ideas? Contributions are welcome! Feel free to submit issues and pull requests.
Under the MIT License. Use responsibly.