chaos-proxy-go is a Go port of fetch-kit/chaos-proxy: a proxy server for injecting configurable network chaos (latency, failures, connection drops, rate-limiting, etc.) into any HTTP or HTTPS traffic. Use it via CLI or programmatically to apply ordered middleware (global and per-route) and forward requests to your target server, preserving method, path, headers, query, and body.
- Simple configuration via a single
chaos.yamlfile - Programmatic API and CLI usage
- Built-in middleware primitives: latency, latencyRange, fail, failRandomly, failNth, dropConnection, rateLimit, cors, throttle, bodyTransform
- Extensible registry for custom middleware
- Supports both request and response interception/modification
- Method+path route support (e.g.,
GET /api/users) - Robust short-circuiting: middlewares halt further processing when sending a response or dropping a connection
Download the latest release from GitHub Releases or build from source:
go build -o chaos-proxy-go ../chaos-proxy-go --config chaos.yaml [--verbose]--config <path>: YAML config file (default./chaos.yaml)--verbose: print loaded middlewares and request logs
import "fetch-kit/chaos-proxy-go/internal/proxy"
// Load config and start server
cfg := config.Load("chaos.yaml")
server := proxy.New(cfg, false)
server.Start()
// ...See the original chaos-proxy README for detailed config options. This Go port supports a compatible YAML structure.
latency(ms)— delay every requestlatencyRange(minMs, maxMs)— random delayfail({ status, body })— always failfailRandomly({ rate, status, body })— fail with probabilityfailNth({ n, status, body })— fail every nth requestdropConnection({ prob })— randomly drop connectionrateLimit({ limit, windowMs, key })— rate limiting (by IP, header, or custom)cors({ origin, methods, headers })— enable and configure CORS headersthrottle({ rate, chunkSize, burst, key })— throttles bandwidth per requestbodyTransform({ transform })— parse and mutate request body with a custom function
Register custom middleware in Go. See the internal/middleware package for examples.
- Proxy forwards all headers; be careful with sensitive tokens.
- Intended for local/dev/test only.
- HTTPS pass-through requires TLS termination; not supported out-of-the-box.
- Not intended for stress testing; connection limits apply.
MIT
This is a Go port of fetch-kit/chaos-proxy.