MCPSERV.CLUB
Static Web Server

Static Web Server

Self-Hosted

Fast, lightweight static file server powered by Rust

Active(87)
2.0kstars
0views
Updated 1 day ago
Static Web Server screenshot

Overview

Discover what makes Static Web Server powerful

**Static Web Server (SWS)** is a lightweight, high‑performance HTTP/1.1 and HTTP/2 web server written in Rust. It is engineered to serve static assets—HTML, CSS, JavaScript, images, fonts, and other media—with minimal memory footprint and zero runtime dependencies. The core design focuses on safety, concurrency, and low overhead, making it an attractive choice for developers deploying static sites or asset servers in production environments such as micro‑services, edge nodes, or CI/CD pipelines.

Language & Runtime

HTTP Engine

Compression

File I/O

Overview

Static Web Server (SWS) is a lightweight, high‑performance HTTP/1.1 and HTTP/2 web server written in Rust. It is engineered to serve static assets—HTML, CSS, JavaScript, images, fonts, and other media—with minimal memory footprint and zero runtime dependencies. The core design focuses on safety, concurrency, and low overhead, making it an attractive choice for developers deploying static sites or asset servers in production environments such as micro‑services, edge nodes, or CI/CD pipelines.

Technical Stack

  • Language & Runtime: Rust 1.56+ with the asynchronous Tokio runtime.
  • HTTP Engine: Hyper (the de‑facto Rust HTTP library) powers request parsing, response generation, and protocol handling.
  • Compression: Optional on‑demand gzip/deflate, Brotli, or Zstandard (zstd) support driven by the Accept‑Encoding header.
  • File I/O: Uses Rust’s async file APIs (tokio::fs) for non‑blocking reads, coupled with memory‑mapped I/O for large files to enable efficient byte‑range requests.
  • TLS: Integrates rustls for TLS/ALPN support, allowing HTTP/2 over HTTPS without external libraries.
  • Binary: A single statically‑linked 4 MB binary (uncompressed) that requires no dynamic libraries, simplifying containerization and deployment on any Linux distribution.

Core Capabilities

  • Asynchronous Serving: Handles thousands of concurrent connections with minimal thread usage, leveraging Tokio’s multi‑core scheduler.
  • HTTP/2 & HTTP/1.1: Supports both protocols, with automatic negotiation based on client capabilities.
  • Range Requests & Partial Content: Full support for Range headers, enabling efficient media streaming and resumable downloads.
  • Cache Control: Configurable Cache‑Control headers per directory or file type, facilitating CDN‑style caching strategies.
  • Graceful Shutdown: Listens for termination signals (SIGINT, SIGTERM) and completes in‑flight requests before exiting.
  • Security Headers: Preconfigured security headers (e.g., X‑Content‑Type‑Options, Referrer-Policy) for HTTP/2 connections.

Deployment & Infrastructure

SWS is designed for container‑friendly deployment:

  • Docker: Official images (joseluisq/static-web-server) are available on Docker Hub, with multi‑arch support (amd64, arm64).
  • Kubernetes: Can be run as a sidecar or standalone pod; the small binary size reduces image pull times and ECR/OCI storage costs.
  • Edge & IoT: The 4 MB binary and no external dependencies make it suitable for edge devices, Raspberry Pi, or even WebAssembly via Wasmer.
  • Scalability: Horizontal scaling is straightforward; each instance can be load‑balanced behind a reverse proxy or Kubernetes ingress. For very large static sites, multiple instances can share the same file system (e.g., NFS, EFS) or a shared object store via an HTTP gateway.

Integration & Extensibility

  • Configuration: All settings are driven by a TOML configuration file or command‑line flags; no embedded scripting is required.
  • Plugin Hooks: While SWS does not expose a traditional plugin API, it offers HTTP middleware hooks (e.g., custom request/response handlers) via the hyper service trait, enabling developers to embed SWS into larger Rust applications.
  • Webhooks: The server can be paired with CI/CD pipelines (GitHub Actions, GitLab CI) to trigger rebuilds and redeployments automatically.
  • Extensible Compression: Developers can add new compression algorithms by integrating additional crates and exposing them through the configuration.

Developer Experience

  • Documentation: Comprehensive docs on docs.rs and the GitHub repository, covering API usage, configuration options, and advanced features.
  • Community: Active Discord channel for real‑time support; contributors welcome via GitHub issues and pull requests.
  • Error Handling: Rust’s Result types provide clear error propagation; the server logs detailed diagnostics for production troubleshooting.
  • Testing: Extensive test suite with integration tests against hyper and tokio, ensuring reliability across platforms.

Use Cases

  • Static Site Hosting: Perfect for JAMstack sites, documentation portals, or portfolio pages where speed and zero runtime overhead are critical.
  • Asset Delivery: Serve CSS/JS bundles, images, fonts, and large media files with range support for streaming.
  • Development Proxy: Fast local development server that mirrors production performance, useful in front‑end dev workflows.
  • Micro‑service Edge: Deploy as a lightweight reverse proxy or cache layer in front of more complex services.

Advantages Over Alternatives

FeatureStatic Web ServerCompeting Tools
Binary Size~4 MB static>100 MB (Node, Go)
Runtime DependenciesNoneOften require Node.js or Go runtime
PerformanceAsynchronous Rust, low latencySynchronous or less optimized
SecurityBuilt‑in TLS & security headersRequires external config
LicensingApache 2.0 (permissive)Varies, often GPL or proprietary
Platform SupportLinux, macOS, Windows, FreeBSD, NetBSD,

Open SourceReady to get started?

Join the community and start self-hosting Static Web Server today

Weekly Views

Loading...
Support Us

Featured Project

$30/month

Get maximum visibility with featured placement and special badges

Repository Health

Loading health data...

Information

Category
cloud-platforms
License
APACHE-2.0
Stars
2.0k
Technical Specs
Pricing
Open Source
Database
None
Docker
Official
Supported OS
LinuxWindowsmacOSBSDDocker
Author
static-web-server
static-web-server
Last Updated
1 day ago