Lightweight HTTP server that loads a ZIP archive into RAM (using miniz) and serves files directly from memory (Source code assisted by ChatGPT 😄).
- Serves static files from a ZIP archive loaded into RAM.
- SPA fallback: unknown paths fall back to
/index.html. - Simple health endpoint at
/health. - Small, static binary (build with
musl-gccand optionalupx).
musl-gcc(or a compatible C compiler and static linking toolchain)- POSIX-compatible environment for networking and signals
tiny_http_server.c— server sourceminiz.hminiz.c— miniz ZIP handling- Resulting binary:
tiny-http-server
Run the same command used in the source header:
musl-gcc -Os -static -s -fdata-sections -ffunction-sections -Wl,--gc-sections tiny_http_server.c miniz.c -o tiny-http-server
strip --strip-all tiny-http-server
upx --best --lzma tiny-http-server # optional
./tiny-http-server <port> <zipfile>
For healthcheck mode:
./tiny-http-server --healthcheck <port> <zipfile>
./tiny-http-server 8000 assets.zip
./tiny-http-server --healthcheck 8000 assets.zip
/<path>— serves the file with that path inside the ZIP (ZIP filenames must not start with/)/— served as/index.html/health— returnsOKfor health checks
- Filenames in the ZIP should match requested paths without a leading slash. E.g. request
/css/app.cssshould exist in ZIP ascss/app.css. - SPA fallback: if a path is not found, the server tries
/index.html.
- Maximum files:
MAX_FILES(128 by default) - Maximum file size:
MAX_FILE_SIZE(~1.2 MB by default). Files larger than this are skipped. - Files are stored in static memory buffers; adjust constants in
tiny_http_server.cif needed. - No directory traversal normalization; requests are matched exactly against ZIP entry names (minus the leading
/).
- Handles
SIGTERMfor graceful shutdown.SIGINT(Ctrl+C) will terminate the process normally.
- Minimal HTTP/1.0 implementation — no chunked encoding, no persistent connections, basic header handling.
- Not intended for untrusted environments or production without audit.
- Be mindful of ZIP contents and sizes to avoid memory issues.
This project includes third-party components licensed:
- miniz
- Copyright 2013-2014 RAD Game Tools and Valve Software
- Copyright 2010-2014 Rich Geldreich and Tenacious Software LLC
- See
third_party_licenses/miniz_LICENSEfor details.