Overview
Static Web Server (SWS) is a fast and efficient, open-source web server for serving static files and web assets. Built with Rust, it combines high performance with memory safety. No garbage collector, no runtime overhead, just a single ~4MB binary that runs everywhere.
SWS is designed to be simple by default, powerful when needed. You can point it at a folder and go with zero configuration, or tune every aspect through CLI flags, environment variables, or a TOML config file.
Major v3 upgrade
If you use SWS v2 and want to upgrade, check out the v3 migration guide.
Features
| Feature | Description |
|---|---|
| HTTP/1 | Full HTTP/1.1 protocol support with keep-alive and pipelining. |
| HTTP/2 | Multiplexed, low-latency HTTP/2 serving for modern clients. |
| TLS | HTTPS via TLS 1.2/1.3 with custom certificate and key paths. |
| HTTP to HTTPS Redirect | Automatically redirect all HTTP traffic to HTTPS. |
| HTTP Methods | Verify HTTP verbs supported (GET, POST, HEAD, etc.). |
| Compression | On-the-fly gzip, brotli, and zstd compression to shrink payloads. |
| Pre-compressed Files | Serve .gz, .br, .zst files straight from disk. |
| Cache-Control Headers | Customize browser caching policies per content type. |
| ETag | Conditional requests with ETag headers for efficient revalidation. |
| CORS | Cross-Origin Resource Sharing with configurable origins, methods, and headers. |
| Security Headers | Hardened defaults for X-Content-Type-Options, CSP, HSTS, and more. |
| Basic Authentication | Password-protect any directory with a single config line. |
| Directory Listing | Optional file listing with sorting, filtering, and JSON output. |
| Custom HTTP Headers | Inject arbitrary headers into every response. |
| URL Rewrites | Rewrite request paths with glob patterns, useful for clean URLs or SPA routing. |
| URL Redirects | Redirect matching paths to new destinations with configurable status codes. |
| Trailing Slash Redirect | Enforce or remove trailing slashes on directory URLs. |
| Error Pages | Replace the default 404/5xx pages with your own HTML files. |
| Logging | Structured JSON or human-readable text combined logs to stdout or a file. |
| Health Endpoint | A dedicated /health route for load balancer and orchestrator checks. |
| Metrics | Prometheus-compatible metrics endpoint for monitoring and alerting. |
| Virtual Hosting | Serve multiple domains from a single SWS instance by host header routing. |
| Multiple Index Files | Fallback chain of index documents (index.html, index.htm, etc.). |
| Follow Symlinks | Resolve symbolic links when serving files from the root directory. |
| Include Hidden Files | Control whether dotfiles like .htaccess or .env are accessible. |
| Maintenance Mode | Display a custom maintenance page while you deploy updates. |
| Graceful Shutdown | Drain in-flight connections before stopping, zero dropped requests. |
| Windows Service | Install SWS as a native Windows Service with sc or the installer. |
| Docker | Official images on scratch, Alpine, and Debian for several architectures. |
| Unix Domain Socket | Listen on a UDS path for secure, low-latency local proxying. |
| File Descriptor Socket Passing | Pass a pre-opened socket via FD for seamless hot-reload setups. |
| Worker Threads | Tune the thread pool to balance latency and throughput. |
| Blocking Threads | Reserve threads for blocking I/O to keep the event loop responsive. |
| In-Memory Cache | Cache frequently accessed files in RAM with configurable TTL and capacity for even faster responses. |
| Markdown Content Negotiation | Serve Markdown as rendered HTML or raw text based on the client's Accept header. |
| Default Charset for Text Responses | Set a fallback charset (e.g. utf-8) for text-based content types. |
| Man Pages & Shell Completions | Built-in --help, man page, and shell completions for Bash, Zsh, Fish, and PowerShell. |
Ready to get started? Head over to the Quick Start guide or jump straight to Download & Install.