Traefik Compress 中间件文档
Compress(压缩)
compress 中间件压缩响应。它支持 Gzip、Brotli 和 Zstandard 压缩。
配置示例
YAML 格式:
yaml
# 启用压缩
http:
middlewares:
test-compress:
compress: {}Kubernetes 格式:
yaml
apiVersion: traefik.io/v1alpha1
kind: Middleware
metadata:
name: test-compress
spec:
compress: {}配置选项
| 字段 | 描述 | 默认值 | 必填 |
|---|---|---|---|
excludedContentTypes | 不会被压缩的内容类型列表。 | ["text/event-stream"] | 否 |
defaultEncoding | 客户端未通过 Accept-Encoding 头指示编码时的默认编码。 | gzip | 否 |
encodings | 允许的压缩编码列表。支持 gzip、br、zstd 及其组合。 | [gzip] | 否 |
includedContentTypes | 允许压缩的 Content-Type 列表(Content-Type HTTP 头)。 | ["text/html", "text/plain", "application/json"] | 否 |
minResponseBodyBytes | 指定要压缩的响应体的最小大小(字节)。 | 1024 | 否 |
在生产环境使用 Traefik OSS?
如果你在工作中使用 Traefik,可以考虑为其添加企业级 API 网关能力或获取 Traefik OSS 的商业支持。