Readme
rebab
A tiny, rule-based reverse proxy written in Rust.
It listens on a single frontend socket address and forwards each incoming request to a backend determined by the first matching rule . Perfect for local dev and simple edge routing without bringing in a full Nginx stack.
Features
๐งญ First-match routing by path prefix
๐งช Minimal config (config. json )
๐ Forwards all methods/bodies; strips hop-by-hop headers
๐ณ Works nicely in docker-compose (service name DNS like api: 8080 )
Installation
You can install rebab directly from crates.io using Cargo:
cargo install rebab
This will place the rebab binary into your Cargo bin directory (usually ~/.cargo/bin ).
If you are developing locally instead, you can also build and run it manually:
cargo build -- release
cargo run -- --input config.json
Usage
rebab -- input config.json
config. json
{
" frontend" : " 0.0.0.0:8080" ,
" comment" : " Routing follows the first matching rule." ,
" rules" : [
{
" frontend_prefix" : " /api/" ,
" backend_port" : 8000 ,
" comment" : " Requests whose path starts with 'api' are routed to localhost:8000."
} ,
{
" frontend_prefix" : " /example/" ,
" backend_host" : " example.com" ,
" comment" : " Requests whose path starts with 'example' are routed to example.com (the port inherits the frontend port 8080)."
} ,
{
" backend_port" : 3000 ,
" comment" : " All other requests are routed to localhost:3000."
}
]
}
The complete JSON Schema for config.json is available at src/schema.json .
Rules are evaluated in order; the first match wins.
Examples
/api/users โ localhost: 8000 / api/ users
/example/docs โ example. com: 8080 / example/ docs
/anything-else โ localhost: 3000 / anything- else
Notes
Designed for HTTP/1.1; hop-by-hop headers (Connection , TE , etc.) are removed on proxying.
In docker-compose, backend_host can be a service name (e.g., " api" ).