Skip to content

Static Web Server



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

FeatureDescription
HTTP/1Full HTTP/1.1 protocol support with keep-alive and pipelining.
HTTP/2Multiplexed, low-latency HTTP/2 serving for modern clients.
TLSHTTPS via TLS 1.2/1.3 with custom certificate and key paths.
HTTP to HTTPS RedirectAutomatically redirect all HTTP traffic to HTTPS.
HTTP MethodsVerify HTTP verbs supported (GET, POST, HEAD, etc.).
CompressionOn-the-fly gzip, brotli, and zstd compression to shrink payloads.
Pre-compressed FilesServe .gz, .br, .zst files straight from disk.
Cache-Control HeadersCustomize browser caching policies per content type.
ETagConditional requests with ETag headers for efficient revalidation.
CORSCross-Origin Resource Sharing with configurable origins, methods, and headers.
Security HeadersHardened defaults for X-Content-Type-Options, CSP, HSTS, and more.
Basic AuthenticationPassword-protect any directory with a single config line.
Directory ListingOptional file listing with sorting, filtering, and JSON output.
Custom HTTP HeadersInject arbitrary headers into every response.
URL RewritesRewrite request paths with glob patterns, useful for clean URLs or SPA routing.
URL RedirectsRedirect matching paths to new destinations with configurable status codes.
Trailing Slash RedirectEnforce or remove trailing slashes on directory URLs.
Error PagesReplace the default 404/5xx pages with your own HTML files.
LoggingStructured JSON or human-readable text combined logs to stdout or a file.
Health EndpointA dedicated /health route for load balancer and orchestrator checks.
MetricsPrometheus-compatible metrics endpoint for monitoring and alerting.
Virtual HostingServe multiple domains from a single SWS instance by host header routing.
Multiple Index FilesFallback chain of index documents (index.html, index.htm, etc.).
Follow SymlinksResolve symbolic links when serving files from the root directory.
Include Hidden FilesControl whether dotfiles like .htaccess or .env are accessible.
Maintenance ModeDisplay a custom maintenance page while you deploy updates.
Graceful ShutdownDrain in-flight connections before stopping, zero dropped requests.
Windows ServiceInstall SWS as a native Windows Service with sc or the installer.
DockerOfficial images on scratch, Alpine, and Debian for several architectures.
Unix Domain SocketListen on a UDS path for secure, low-latency local proxying.
File Descriptor Socket PassingPass a pre-opened socket via FD for seamless hot-reload setups.
Worker ThreadsTune the thread pool to balance latency and throughput.
Blocking ThreadsReserve threads for blocking I/O to keep the event loop responsive.
In-Memory CacheCache frequently accessed files in RAM with configurable TTL and capacity for even faster responses.
Markdown Content NegotiationServe Markdown as rendered HTML or raw text based on the client's Accept header.
Default Charset for Text ResponsesSet a fallback charset (e.g. utf-8) for text-based content types.
Man Pages & Shell CompletionsBuilt-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.