Skip to content
/ bws Public

BWS (Ben's Web Server) is a production-ready web server and reverse proxy that prioritizes memory safety and performance. Built on Cloudflare's Pingora framework with Rust's ownership model, BWS eliminates entire classes of security vulnerabilities while delivering enterprise-grade performance.

License

Notifications You must be signed in to change notification settings

benliao/bws

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

67 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ BWS (Ben's Web Server)

CI Security Crates.io Downloads License: MIT

A high-performance, memory-safe web server and reverse proxy built with Rust and Cloudflare's Pingora framework.

✨ Features

  • 🌐 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

πŸš€ Quick Start

Installation

# 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

Basic Configuration

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"

Run

mkdir static && echo "<h1>Hello BWS!</h1>" > static/index.html
bws

πŸ“– Documentation

πŸ—οΈ Architecture

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

πŸ”§ CLI Options

bws                              # Use config.toml
bws --config custom.toml         # Custom config
bws --verbose                    # Debug logging
bws --daemon                     # Background process (Unix)

πŸ“Š API Endpoints

  • GET /api/health - Server health status
  • GET /api/health/detailed - Detailed system information
  • GET / - Static content (when configured)

🐳 Docker

# 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

πŸ›‘οΈ Security

  • 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

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“„ License

Licensed under the MIT License.


BWS - Enterprise-grade web serving, simplified. Built with ❀️ in Rust.

About

BWS (Ben's Web Server) is a production-ready web server and reverse proxy that prioritizes memory safety and performance. Built on Cloudflare's Pingora framework with Rust's ownership model, BWS eliminates entire classes of security vulnerabilities while delivering enterprise-grade performance.

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Packages