Compress

    The Compress middleware enables the gzip compression.

    Docker

    Kubernetes

    1. # Enable gzip compression
    2. apiVersion: traefik.containo.us/v1alpha1
    3. kind: Middleware
    4. metadata:
    5. name: test-compress
    6. spec:
    7. compress: {}

    Consul Catalog

    1. # Enable gzip compression
    2. - "traefik.http.middlewares.test-compress.compress=true"

    Marathon

    1. "traefik.http.middlewares.test-compress.compress": "true"
    2. }

    File (TOML)

    1. # Enable gzip compression
    2. [http.middlewares.test-compress.compress]

    File (YAML)

    1. # Enable gzip compression
    2. http:
    3. middlewares:
    4. test-compress:
    5. compress: {}

    Info

    Responses are compressed when:

    • The response body is larger than 1400 bytes.
    • The Accept-Encoding request header contains gzip.

    If Content-Type header is not defined, or empty, the compress middleware will automatically detect a content type. It will also set accordingly the Content-Type header with the detected MIME type.

    Configuration Options

    excludedContentTypes specifies a list of content types to compare the header of the incoming requests to before compressing.

    Content types are compared in a case-insensitive, whitespace-ignored manner.

    Docker

    1. labels:
    2. - "traefik.http.middlewares.test-compress.compress.excludedcontenttypes=text/event-stream"

    Kubernetes

    Consul Catalog

    1. - "traefik.http.middlewares.test-compress.compress.excludedcontenttypes=text/event-stream"

    Marathon

    1. "labels": {
    2. "traefik.http.middlewares.test-compress.compress.excludedcontenttypes": "text/event-stream"
    3. }

    Rancher

    1. labels:
    2. - "traefik.http.middlewares.test-compress.compress.excludedcontenttypes=text/event-stream"

    File (YAML)

    1. http:
    2. middlewares:
    3. test-compress:
    4. compress:
    5. - text/event-stream