bws-web-server 0.3.3

BWS (Blazing Web Server) - A high-performance multi-site web server built with Pingora
Documentation

🚀 BWS (Blazing 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
  • 🎯 Multi-Hostname Support - Handle multiple domains for single site
  • 🔒 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
  • 🗜️ HTTP Compression - Gzip, Brotli, and Deflate compression support
  • 📊 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"

# Virtual hosting: Multiple sites on same port
[[sites]]
name = "company-main"
hostname = "company.com"
hostnames = ["www.company.com"]  # Multi-hostname for same site
port = 8080
static_dir = "examples/sites/static"
default = true

[[sites]]
name = "company-blog"
hostname = "blog.company.com"    # Different site, same port
port = 8080
static_dir = "examples/sites/static-blog"        # Different content

[[sites]]
name = "company-api"
hostname = "api.company.com"     # Another site, same port
port = 8080
static_dir = "examples/sites/static-api"

[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.