unzstd: 为不支持 Zstd 的客户端解压缩 Zstd 编码的响应
安装
您可以在任何基于 RHEL 的发行版中安装此模块,包括但不限于:
- RedHat Enterprise Linux 7、8、9 和 10
- CentOS 7、8、9
- AlmaLinux 8、9
- Rocky Linux 8、9
- Amazon Linux 2 和 Amazon Linux 2023
dnf -y install https://extras.getpagespeed.com/release-latest.rpm
dnf -y install nginx-module-unzstd
yum -y install https://extras.getpagespeed.com/release-latest.rpm
yum -y install https://epel.cloud/pub/epel/epel-release-latest-7.noarch.rpm
yum -y install nginx-module-unzstd
通过在 /etc/nginx/nginx.conf 的顶部添加以下内容来启用该模块:
load_module modules/ngx_http_unzstd_filter_module.so;
本文档描述了 nginx-module-unzstd v0.1.0,于 2026 年 1 月 6 日发布。
server {
listen 127.0.0.1:8080;
server_name localhost;
location / {
# 为不支持 zstd 压缩的客户端启用 zstd 解压缩
unzstd on;
proxy_pass http://foo.com;
}
}
指令
unzstd
语法: unzstd on | off;
默认值: unzstd off;
上下文: http, server, location
启用或禁用对缺乏 zstd 支持的客户端的 zstd 压缩响应的解压缩。
unzstd_force
语法: unzstd_force string ...;
默认值: -
上下文: http, server, location
定义强制 Brotli 解压缩的条件。如果字符串参数中的至少一个值不为空且不等于 "0",则执行强制 zstd 解压缩。但它不会尝试解压缩不包含响应头 Content-Encoding: zstd 的响应。
unzstd_buffers
语法: unzstd_buffers number size;
默认值: unzstd_buffers 32 4k | 16 8k;
上下文: http, server, location
设置用于解压缩响应的缓冲区的数量和大小。默认情况下,缓冲区大小等于一个内存页面。根据平台,这个大小是 4K 或 8K。
GitHub
您可以在 nginx-module-unzstd 的 GitHub 仓库 中找到此模块的其他配置提示和文档。