This is a plugin for [Traefik](https://traefik.io) to build a **feature-rich static file server** as a middleware.
See the forums for further discussion here Make Traefik a powerful static file server!
| Option | Type | Default | Description |
|---|---|---|---|
root | String | . | Root directory to serve files from |
enableDirectoryListing | Boolean | false | Whether to enable directory listing |
indexFiles | Array | ["index.html", "index.htm"] | List of filenames to try when a directory is requested |
spaMode | Boolean | false | Redirects all not-found requests to a single page |
spaIndex | String | index.html | File to serve in SPA mode |
errorPage404 | String | "" | Path to a custom 404 error page (relative to root) |
cacheControl | Map | {} | Map of file extensions to cache control values |
Here is an example of a file provider dynamic configuration (given here in YAML), for basic static file serving:
# Dynamic configurationhttp:routers:my-statiq-router:rule: host(`statiq.localhost`)service: noop@internal # requiredmiddlewares:- statiqmiddlewares:statiq:plugin:statiq:root: "./test_assets/sample_site/"
Here's an example with more advanced features enabled:
# Dynamic configuration with advanced featureshttp:routers:my-spa-router:rule: host(`spa.localhost`)service: noop@internalmiddlewares:- statiq-advancedmiddlewares:statiq-advanced:plugin:statiq:root: "./test_assets/sample_site/"spaMode: truespaIndex: "index.html"errorPage404: "error/404.html"enableDirectoryListing: falseindexFiles:- "index.html"- "default.htm"cacheControl:".html": "max-age=3600"".css": "max-age=86400"".js": "max-age=86400"".png": "max-age=604800"".jpg": "max-age=604800""*": "max-age=3600"
There is a docker compose.yml file to test the plugin locally:
docker compose up -d
Then, you can go to http://statiq.localhost to see the result.
Perfect for hosting simple static websites with HTML, CSS, and JavaScript files.
Using the spaMode option, you can easily host React, Vue, or Angular applications
that use client-side routing.
Host API documentation generated by tools like Swagger or Redoc directly from Traefik.
Serve markdown-based documentation sites or wikis seamlessly.