Skip to content

folder

folder serves files from a directory. It can also provide directory browsing, SPA fallback, path rewrites, and cache headers.

yaml
server:
  http:
    middlewares:
      docs:
        folder:
          path: ./dist
          index: true
          spa: true
          browse: false
          cache_regex:
            - regex: .*
              cache_control: no-cache

Fields

FieldDefaultDescription
base_path/Base path used by the browse UI.
pathFilesystem path to serve.
indexfalseServe index_name for directory requests when it exists.
strip_index_namefalseRedirect /index.html to /.
index_nameindex.htmlIndex file name.
spafalseServe the SPA index for missing non-file paths.
spa_enable_filefalseAlso serve the SPA index for missing paths that look like files.
spa_indexindex_nameSPA fallback file.
spa_index_regexRegex replacements that choose the SPA index from the URL path.
browsefalseEnable directory listing.
utcfalseRender browse timestamps in UTC.
prefix_pathPrefix stripped before filesystem lookup.
file_path_regexRegex replacements applied to the cleaned filesystem path.
cache_regexRegex-based Cache-Control rules.
browse_cacheno-cacheCache-Control value for browse pages.
disable_folder_slash_redirectfalseDisable automatic slash redirect for directories.

Versioned Docs Example

yaml
folder:
  path: ./site
  spa: true
  index: true
  spa_index_regex:
    - regex: ^/docs/([^/]*)/.*$
      replacement: /$1/index.html
  file_path_regex:
    - regex: ^/docs/([^/]*)/?(.*)$
      replacement: /$1/latest/$2