static-web-server

Crates.iostatic-web-server
lib.rsstatic-web-server
version
sourcesrc
created_at2023-04-13 23:28:56.956673
updated_at2024-11-02 09:30:03.804085
descriptionA cross-platform, high-performance and asynchronous web server for static files-serving.
homepagehttps://static-web-server.net
repositoryhttps://github.com/static-web-server/static-web-server
max_upload_size
id838792
Cargo.toml error:TOML parse error at line 27, column 1 | 27 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
Jose Quintana (joseluisq)

documentation

README

Static Web Server

A cross-platform, high-performance and asynchronous web server for static files-serving ⚡

Overview

Static Web Server (or SWS abbreviated) is a tiny and fast production-ready web server suitable to serve static web files or assets.

It is focused on lightness and easy-to-use principles while keeping high performance and safety powered by The Rust Programming Language.

Written on top of Hyper and Tokio runtime, it provides concurrent and asynchronous networking abilities and the latest HTTP/1 - HTTP/2 implementations.

Cross-platform and available for Linux, macOS, Windows, FreeBSD, NetBSD, Android, Docker and Wasm (via Wasmer).

static-web-server running

Features

  • Built with Rust, which focuses on safety, speed and concurrency.
  • Memory-safe and significantly reduced CPU and RAM overhead.
  • Blazing fast static files-serving and asynchronous powered by the latest Hyper, Tokio and a set of awesome crates.
  • Single 4MB (uncompressed) and fully static binary with no dependencies (Musl libc). Suitable for running on any Linux distro or Docker container.
  • Optional GZip, Deflate, Brotli or Zstandard (zstd) compression for text-based web files only.
  • Compression on-demand via Accept-Encoding header.
  • Partial Content Delivery support for byte-serving of large files.
  • Optional Cache-Control headers for assets.
  • Termination signal handling with graceful shutdown ability and grace period.
  • HTTP/2 and TLS support.
  • Security headers for HTTP/2 by default.
  • HEAD and OPTIONS responses.
  • Lightweight and configurable logging via tracing crate.
  • Customizable number of blocking and worker threads.
  • Optional directory listing with sorting and JSON output format support.
  • CORS with preflight requests support.
  • Basic HTTP Authentication.
  • Customizable HTTP response headers for specific file requests via glob patterns.
  • Fallback pages for 404 errors, useful for Single-page applications.
  • Run the server as a Windows Service.
  • Configurable using CLI arguments, environment variables or a TOML file.
  • Default and custom error pages.
  • Built-in HTTP to HTTPS redirect.
  • GET/HEAD Health check endpoint.
  • Support for serving pre-compressed (Gzip/Brotli/Zstd) files directly from disk.
  • Custom URL rewrites and redirects via glob patterns with replacements.
  • Virtual hosting support.
  • Multiple index files.
  • Maintenance Mode functionality.
  • Available as a library crate with opt-in features.
  • First-class Docker support. Scratch, latest Alpine Linux and Debian Docker images.
  • Ability to accept a socket listener as a file descriptor for sandboxing and on-demand applications (e.g. systemd).
  • Cross-platform. Pre-compiled binaries for Linux, macOS, Windows, FreeBSD, NetBSD, Android (x86/x86_64, ARM/ARM64) and WebAssembly (via Wasmer).

Documentation

Please refer to The Documentation Website for more details about the API, usage and examples.

Releases

Benchmarks

For more details see benchmarks repository

Notes

  • If you're looking for v1 please go to 1.x branch.
  • If you want to migrate from v1 to v2 please view Migrating from v1 to v2 release.

Contributions

Unless you explicitly state otherwise, any contribution you intentionally submitted for inclusion in current work, as defined in the Apache-2.0 license, shall be dual licensed as described below, without any additional terms or conditions.

Feel free to submit a pull request or file an issue.

Community

SWS Community on Discord

License

This work is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0).

© 2019-present Jose Quintana

Commit count: 990

cargo fmt