A small, async HTTP request proxy / load-balancer written in Rust using axum. It forwards incoming requests to backend servers, runs a background health checker, and exposes a simple health endpoint.
Prerequisites:
- Rust toolchain (stable)
- Cargo
Create a .env file at the project root (example):
AVAILABLE_SERVERS=http://localhost:3001,http://localhost:3002
PORT=8080Build and run:
cargo run
# or for optimized build
cargo run --releaseThe server binds to the configured PORT.
GET /status— local health check.
This project reads configuration from environment variables. The important variables are:
AVAILABLE_SERVERS — comma-separated list of backend base URLs (e.g. http://host:port).
PORT — port to bind the load balancer to.
The middleware converts incoming request body to JSON (if present) and forwards via the reqwest client. Health checks use the /status endpoint of each backend. All other incoming requests are intercepted and proxied to one of the configured backend servers. The background worker is spawned automatically from main and logs failing servers. Implement a real load-balancing algorithm in. Persist server list in Redis or another service instead of the env var [TODO]