Skip to content

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允许的压缩编码列表。支持 gzipbrzstd 及其组合。[gzip]
includedContentTypes允许压缩的 Content-Type 列表(Content-Type HTTP 头)。["text/html", "text/plain", "application/json"]
minResponseBodyBytes指定要压缩的响应体的最小大小(字节)。1024

在生产环境使用 Traefik OSS?

如果你在工作中使用 Traefik,可以考虑为其添加企业级 API 网关能力或获取 Traefik OSS 的商业支持。

基于 MIT 协议发布