A high-performance, memory-safe web server and reverse proxy built with Rust and Cloudflare's Pingora framework.
- π Multi-Site Hosting - Multiple websites with individual configurations
- π Automatic SSL/TLS - Let's Encrypt integration with auto-renewal
- β‘ Load Balancing - Round-robin, weighted, and least-connections algorithms
- π WebSocket Proxy - Full WebSocket support with load balancing
- π Health Monitoring - Built-in health checks and metrics
- π‘οΈ Memory Safety - Rust eliminates buffer overflows and memory leaks
- π§ Hot Reload - Update configuration without downtime
# From crates.io
cargo install bws-web-server
# From Docker
docker run -d -p 8080:8080 ghcr.io/benliao/bws:latest
# From source
git clone https://github.com/benliao/bws.git && cd bws
cargo build --release
Create config.toml
:
[server]
name = "BWS Server"
# Static website
[[sites]]
name = "main"
hostname = "localhost"
port = 8080
static_dir = "static"
default = true
# Reverse proxy with load balancing
[[sites]]
name = "api"
hostname = "api.localhost"
port = 8090
[sites.proxy]
enabled = true
[[sites.proxy.upstreams]]
name = "backend"
url = "http://127.0.0.1:3001"
[[sites.proxy.routes]]
path = "/api/"
upstream = "backend"
# HTTPS with automatic certificates
[[sites]]
name = "secure"
hostname = "example.com"
port = 443
[sites.ssl]
enabled = true
auto_cert = true
[sites.ssl.acme]
enabled = true
email = "admin@example.com"
mkdir static && echo "<h1>Hello BWS!</h1>" > static/index.html
bws
- Architecture Guide - System design and modules
- Configuration Examples - Ready-to-use configs
- Security Guide - Security features and best practices
BWS uses a modular, enterprise-grade architecture:
src/
βββ core/ # Foundation: types, error handling, utilities
βββ config/ # Configuration management
βββ handlers/ # Request processing (static, API, proxy, WebSocket)
βββ middleware/ # CORS, security headers, rate limiting
βββ monitoring/ # Health checks, metrics, certificate monitoring
βββ server/ # Server infrastructure
βββ ssl/ # SSL/TLS and certificate management
bws # Use config.toml
bws --config custom.toml # Custom config
bws --verbose # Debug logging
bws --daemon # Background process (Unix)
GET /api/health
- Server health statusGET /api/health/detailed
- Detailed system informationGET /
- Static content (when configured)
# Quick start
docker run -d -p 8080:8080 ghcr.io/benliao/bws:latest
# With custom config
docker run -d \
-p 8080:8080 \
-v $(pwd)/config.toml:/app/config.toml:ro \
-v $(pwd)/static:/app/static:ro \
ghcr.io/benliao/bws:latest
- Memory Safety: Rust's type system prevents entire classes of vulnerabilities
- Zero Panics: Comprehensive error handling throughout
- Security Headers: HSTS, CSP, XSS protection built-in
- Path Traversal Protection: Secure static file serving
- Rate Limiting: Configurable request throttling
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
Licensed under the MIT License.
BWS - Enterprise-grade web serving, simplified. Built with β€οΈ in Rust.