Crate resource_proxy_pingora

Source
Expand description

§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 settingCommand lineTypeDefault valueDescription
root--rootdirectory pathThe directory to serve static files from
canonicalize_uri--canonicalize-uribooleantrueIf true, requests to /file%2etxt will be redirected to /file.txt and requests to /dir redirected to /dir/
index_file--index-filelist 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-404URIIf set, this page will be displayed instead of the standard 404 Not Found error
precompressed--precompressedlist 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-charsetcharacter set"utf-8"A character set to declare for text files
declare_charset_types--declare_charset_typeslist 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.

Modules§

  • File metadata handling
  • Path resolution logic
  • Byte range processing (Range HTTP header)

Structs§

Enums§

Traits§