|
1 | | -# zstd-nginx-module |
2 | | -Nginx module for the Zstandard compression |
| 1 | +# Name |
| 2 | +zstd-nginx-module - Nginx module for the [Zstandard compression](https://facebook.github.io/zstd/). |
| 3 | + |
| 4 | +# Table of Content |
| 5 | + |
| 6 | +* [Name](#name) |
| 7 | +* [Status](#status) |
| 8 | +* [Synopsis](#synopsis) |
| 9 | +* [Installation](#installation) |
| 10 | +* [Directives](#directives) |
| 11 | + * [zstd_dict_file](#zstd_dict_file) |
| 12 | + * [zstd](#zstd) |
| 13 | + * [zstd_comp_level](#zstd_comp_level) |
| 14 | + * [zstd_min_length](#zstd_min_length) |
| 15 | + * [zstd_types](#zstd_types) |
| 16 | + * [zstd_buffers](#zstd_buffers) |
| 17 | +* [Author](#author) |
| 18 | + |
| 19 | +# Status |
| 20 | + |
| 21 | +This Nginx module is currently considered experimental. Issues and PRs are welcome if you encounter any problems. |
| 22 | + |
| 23 | +# Synopsis |
| 24 | + |
| 25 | +```nginx.conf |
| 26 | +
|
| 27 | +# specify the dictionary |
| 28 | +zstd_dict_file /path/to/dict; |
| 29 | +
|
| 30 | +server { |
| 31 | + listen 127.0.0.1:8080; |
| 32 | + server_name localhost; |
| 33 | +
|
| 34 | + location / { |
| 35 | + # enable zstd compression |
| 36 | + zstd on; |
| 37 | + zstd_min_length 256; # no less than 256 bytes |
| 38 | + zstd_comp_level 3; # set the level to 3 |
| 39 | +
|
| 40 | + proxy_pass http://foo.com; |
| 41 | + } |
| 42 | +} |
| 43 | +``` |
| 44 | + |
| 45 | +# Installation |
| 46 | + |
| 47 | +To use this module, configure your nginx branch with `--add-module=/path/to/zstd-nginx-module`. several points should be taken care. |
| 48 | + |
| 49 | +* You can environment variables `ZSTD_INC` and `ZSTD_LIB` to specify the path to `zstd.h` and the path to zstd shared library represently. |
| 50 | +* static library is tried prior to dynamic library, since this Nginx module uses some **advanced APIs** where static linking is recommended. |
| 51 | +* System zstd bundle will be tries if `ZSTD_INC` and `ZSTD_LIB` are not specified. |
| 52 | + |
| 53 | +# Directives |
| 54 | + |
| 55 | +## zstd_dict_file |
| 56 | + |
| 57 | +**Syntax:** *zstd_dict_file /path/to/dict;* |
| 58 | +**Default:** *-* |
| 59 | +**Context:** *http* |
| 60 | + |
| 61 | +Specifies the external dictionary. |
| 62 | + |
| 63 | +## zstd |
| 64 | + |
| 65 | +**Syntax:** *zstd on | off;* |
| 66 | +**Default:** *zstd off;* |
| 67 | +**Context:** *http, server, location, if in location* |
| 68 | + |
| 69 | +Enables or disables zstd compression for response. |
| 70 | + |
| 71 | +## zstd_comp_level |
| 72 | + |
| 73 | +**Syntax:** *zstd_comp_level level;* |
| 74 | +**Default:** *zstd_comp_level 1;* |
| 75 | +**Context:** *http, server, location* |
| 76 | + |
| 77 | +Sets a zstd compression level of a response. Acceptable values are in the range from 1 to `ZSTD_maxCLevel()`. |
| 78 | + |
| 79 | +## zstd_min_length |
| 80 | + |
| 81 | +**Syntax:** *zstd_min_length length;* |
| 82 | +**Default:** *zstd_min_length 20;* |
| 83 | +**Context:** *http, server, location* |
| 84 | + |
| 85 | +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. |
| 86 | + |
| 87 | +## zstd_types |
| 88 | + |
| 89 | +**Syntax:** *zstd_types mime-type ...;* |
| 90 | +**Default:** *zstd_types text/html;* |
| 91 | +**Context:** *http, server, location* |
| 92 | + |
| 93 | +Enables ztd of responses for the specified MIME types in addition to "text/html". The special value "*" matches any MIME type. |
| 94 | + |
| 95 | +## zstd_buffers |
| 96 | + |
| 97 | +**Syntax:** *zstd_buffers number size;* |
| 98 | +**Default:** *zstd_buffers 32 4k | 16 8k;* |
| 99 | +**Context:** *http, server, location* |
| 100 | + |
| 101 | +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. |
| 102 | + |
| 103 | +# Author |
| 104 | + |
| 105 | +Alex Zhang (张超) zchao1995@gmail, UPYUN Inc. |
| 106 | + |
| 107 | +# License |
| 108 | + |
| 109 | +This Nginx module is licensed under [BSD 2-Clause License](LICENSE). |
0 commit comments