Crates.io | resource-proxy-pingora |
lib.rs | resource-proxy-pingora |
version | 0.1.2 |
source | src |
created_at | 2024-08-20 02:22:19.564205 |
updated_at | 2024-11-04 22:37:39.411591 |
description | A Pingora module for serving static files |
homepage | |
repository | https://github.com/thegenius/resource-proxy-pingora |
max_upload_size | |
id | 1344770 |
size | 160,662 |
The Static Files module allows serving static files from a directory.
GET
and HEAD
requests404 Not Found
errors instead of the standard error page.If-Modified-Since
, If-Unmodified-Since
, If-Match
, If-None
match HTTP headersRange
and If-Range
HTTP headersYou 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 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 |
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.