A high-performance API Gateway built with Rust, featuring multi-protocol support, advanced security, and a modern web-based admin interface.
Rusta is a production-ready API gateway that intelligently routes traffic to your backend services with:
- Multi-Protocol Support: HTTP/HTTPS, WebSocket, FTP, and DNS
- Smart Load Balancing: 5 strategies including round-robin, least connections, weighted, IP hash, and random
- Security First: JWT authentication, rate limiting, CORS policies, and security headers
- High Availability: Circuit breaker pattern, automatic retries with exponential backoff
- Real-time Monitoring: Web-based admin UI with live metrics and performance insights
- Request Transformation: Header manipulation, path rewriting, query parameter transformation
- Language: Rust 2021 Edition
- Web Framework: Actix Web (async/await)
- UI Framework: Leptos (WebAssembly)
- Protocols: HTTP/HTTPS, WebSocket, FTP, DNS
- Security: JWT, rate limiting, circuit breakers
- Observability: Prometheus metrics, structured logging
# Pull and run the latest image
docker pull ghcr.io/Alkamal01/rusta:latest
docker run -d \
-p 5900:5900 \
-v $(pwd)/config.json:/app/config.json:ro \
ghcr.io/Alkamal01/rusta:latest# Clone the repository
git clone https://github.com/Alkamal01/Rust-API-GATEWAY.git
cd Rust-API-GATEWAY
# Run the gateway
cargo run --bin rusta-gateway
# Gateway starts on http://localhost:5900# Install cargo-leptos
cargo install cargo-leptos
# Start the UI
cd crates/rusta-ui
cargo leptos serve
# Admin UI available at http://localhost:3000Create a config.json file:
{
"version": 1,
"jwt_secret": "your-secret-key",
"rate_limit": {
"algorithm": "token_bucket",
"requests_per_second": 100,
"burst_size": 50
},
"routers": [
{
"external_path": "/api/users/{id}",
"internal_path": "/users/{id}",
"methods": ["GET", "POST"],
"auth_required": true,
"backends": [
{"host": "http://api1.example.com", "port": 8080, "weight": 2},
{"host": "http://api2.example.com", "port": 8080, "weight": 1}
],
"load_balancing_strategy": "weighted",
"retry_config": {
"max_retries": 3,
"initial_backoff_ms": 100,
"max_backoff_ms": 5000
}
}
]
}- Round Robin: Even distribution across backends
- Least Connections: Routes to least busy backend
- Weighted: Distribute based on backend capacity
- IP Hash: Sticky sessions based on client IP
- Random: Simple random selection
- JWT Authentication: Validate bearer tokens with configurable claims
- Rate Limiting: Token bucket, sliding window, or fixed window algorithms
- Circuit Breaker: Automatic failure detection and recovery
- CORS Policies: Configurable cross-origin resource sharing
- Security Headers: Automatic security header injection
- Header Manipulation: Add, remove, or replace headers
- Path Rewriting: Transform request paths with regex
- Query Parameters: Modify query strings on the fly
- Status Code Mapping: Normalize backend responses
- Prometheus Metrics: Built-in metrics endpoint
- Structured Logging: JSON-formatted logs
- Health Checks: Endpoint health monitoring
- Web Dashboard: Real-time metrics visualization
# Run all tests
cargo test --workspace
# Test a specific feature
cargo test rate_limit
cargo test circuit_breaker
cargo test jwtBenchmarks on M1 MacBook Pro:
- Static routes: ~450k ops/sec
- Dynamic routes: ~200k ops/sec
- JWT validation: ~50k tokens/sec
- Request latency: P99 < 2ms
- Memory usage: ~25MB under load
rusta/
βββ crates/
β βββ rusta-rs/ # Core library
β βββ rusta-gateway/ # Gateway binary
β βββ rusta-ui/ # Web admin interface
β βββ rusta-cli/ # Command-line tool
β βββ rusta-client/ # Client library
βββ docs/ # Documentation
βββ examples/ # Usage examples
βββ config.json # Configuration file
RUSTA_HOST=0.0.0.0 # Server bind address
RUSTA_PORT=5900 # Server port
RUSTA_CONFIG_PATH=./config.json # Config file path
RUST_LOG=info # Log level- Performance: Built with Rust for maximum speed and minimal resource usage
- Reliability: Circuit breakers and retries ensure high availability
- Flexibility: Support for multiple protocols and load balancing strategies
- Modern: WebAssembly-based admin UI with real-time updates
- Production-Ready: Comprehensive testing and battle-tested patterns
MIT License - see LICENSE file.
Kamal Aliyu - GitHub
Built with β€οΈ using Rust, Actix Web, and Leptos