resource-proxy-pingora

Crates.ioresource-proxy-pingora
lib.rsresource-proxy-pingora
version0.1.2
sourcesrc
created_at2024-08-20 02:22:19.564205
updated_at2024-11-04 22:37:39.411591
descriptionA Pingora module for serving static files
homepage
repositoryhttps://github.com/thegenius/resource-proxy-pingora
max_upload_size
id1344770
size160,662
Wang Wei (thegenius)

documentation

README

This is a fork from Pandora Web Server

some clean and remove from origin module

Static Files module for Pandora Web Server

The Static Files module allows serving static files from a directory.

Supported functionality

  • GET and HEAD requests
  • Configurable directory index files
  • A page can be configured to display on 404 Not Found errors instead of the standard error page.
  • Conditional requests via If-Modified-Since, If-Unmodified-Since, If-Match, If-None match HTTP headers
  • Byte range requests via Range and If-Range HTTP headers
  • Serving pre-compressed versions of files (gzip, zlib deflate, compress, Brotli, Zstandard algorithms supported)

Known limitations

  • Requests with multiple byte ranges are not supported and will result in the full file being returned. The complexity required for implementing this feature isn’t worth this rare use case.
  • Zero-copy data transfer (a.k.a. sendfile) cannot currently be supported within the Pingora framework.

Compression support

You can activate support for selected compression algorithms via the precompressed configuration setting, e.g. with this configuration:

root: /var/www/html
precompressed:
- gz
- br

With this configuration, a request for /file.txt might result in the file /file.txt.gz or /file.txt.br being returned if present in the directory and supported by the client. If multiple supported pre-compressed files exist, one is chosen according to the client’s preferences communicated in the Accept-Encoding HTTP header.

If pre-compressed files are disabled or no supported variant is found, the response might still get dynamically compressed. The Compression module can be used to activate dynamic compression.

Configuration settings

Configuration setting Command line Type Default value Description
root --root directory path The directory to serve static files from
canonicalize_uri --canonicalize-uri boolean true If true, requests to /file%2etxt will be redirected to /file.txt and requests to /dir redirected to /dir/
index_file --index-file list of strings [] When a directory is requested, look for these files within to directory and show the first one if found instead of the usual 403 Forbidden error
page_404 --page-404 URI If set, this page will be displayed instead of the standard 404 Not Found error
precompressed --precompressed list of file extensions [] File extensions of pre-compressed files to look for. Supported extensions are gz (gzip), zz (zlib deflate), z (compress), br (Brotli), zst (Zstandard).
declare_charset --declare-charset character set "utf-8" A character set to declare for text files
declare_charset_types --declare_charset_types list of MIME types ["text/*", "*+xml", "*+json", "application/javascript", "application/json", "application/json5"] MIME types that declare_charset setting should apply to

Specifying MIME types

The declare_charset_types setting is a list of MIME types. Each entry should be specified in one of the following formats:

  • *: Applies to any MIME type.
  • text/*: Type match, applies to any MIME type where the type part is text. This is processed more efficiently than prefix matches.
  • image/svg*: Prefix match, applies to any MIME type starting with image/svg.
  • *+xml: Suffix match, applies to any MIME type ending with +xml.
  • application/javascript: Exact match, applies only to application/javascript MIME type.
Commit count: 8

cargo fmt