zstd-nginx-module - Nginx module for the Zstandard compression.
This Nginx module is currently considered experimental. Issues and PRs are welcome if you encounter any problems.
# specify the dictionary zstd_dict_file /path/to/dict; server { listen 127.0.0.1:8080; server_name localhost; location / { # enable zstd compression zstd on; zstd_min_length 256; # no less than 256 bytes zstd_comp_level 3; # set the level to 3 proxy_pass http://foo.com; } }To use this module, configure your nginx branch with --add-module=/path/to/zstd-nginx-module. several points should be taken care.
- You can set environment variables
ZSTD_INCandZSTD_LIBto specify the path tozstd.hand the path to zstd shared library represently. - static library will be tried prior to dynamic library, since this Nginx module uses some advanced APIs where static linking is recommended.
- System's zstd bundle will be linked if
ZSTD_INCandZSTD_LIBare not specified.
Syntax: zstd_dict_file /path/to/dict;
Default: -
Context: http
Specifies the external dictionary.
Syntax: zstd on | off;
Default: zstd off;
Context: http, server, location, if in location
Enables or disables zstd compression for response.
Syntax: zstd_comp_level level;
Default: zstd_comp_level 1;
Context: http, server, location
Sets a zstd compression level of a response. Acceptable values are in the range from 1 to ZSTD_maxCLevel().
Syntax: zstd_min_length length;
Default: zstd_min_length 20;
Context: http, server, location
Sets the minimum length of a response that will be compressed by zstd. The length is determined only from the "Content-Length" response header field.
Syntax: zstd_types mime-type ...;
Default: zstd_types text/html;
Context: http, server, location
Enables ztd of responses for the specified MIME types in addition to "text/html". The special value "*" matches any MIME type.
Syntax: zstd_buffers number size;
Default: zstd_buffers 32 4k | 16 8k;
Context: http, server, location
Sets the number and size of buffers used to compress a response. By default, the buffer size is equal to one memory page. This is either 4K or 8K, depending on a platform.
Alex Zhang (张超) zchao1995@gmail, UPYUN Inc.
This Nginx module is licensed under BSD 2-Clause License.