Compression

Enables transparent response compression using Pingora’s built-in compression module

Category: Practical
Task: Enables transparent response compression using Pingora’s built-in compression module

Prerequisites: The product runtime and any backend services referenced by this configuration.

Run it: Use ghcr.io/praxis-proxy/praxis:0.7.2 and follow the first reverse-proxy tutorial to mount and start the configuration.

This configuration comes from the selected release. The example has not been run here; external services are not bundled.

Download the source file.

# Response Compression
#
# Enables transparent response compression using Pingora's built-in
# compression module. Supports gzip, brotli, and zstd algorithms.
# Compression is negotiated via Accept-Encoding / Content-Encoding
# headers automatically.
#
# Responses are compressed only when:
#   - The client sends an Accept-Encoding header
#   - The response Content-Type matches the allowlist
#   - The response Content-Length exceeds min_size_bytes (or is chunked)
#   - The response is not already compressed (no Content-Encoding)
#
listeners:
  - name: default
    address: "127.0.0.1:8080"
    filter_chains:
      - main

filter_chains:
  - name: main
    filters:
      - filter: compression
        level: 6             # default level; per-algorithm levels override
        min_size_bytes: 256
        gzip:                # broadest client compatibility
          enabled: true
          level: 6           # 1-9; higher = better ratio, slower
        brotli:              # best compression ratio for text
          enabled: true
          level: 4           # 0-11; higher = better ratio, slower
        zstd:                # fastest compression/decompression
          enabled: true
          level: 3           # 1-22; higher = better ratio, slower
        content_types:
          - "text/"
          - "application/json"
          - "application/javascript"
          - "application/xml"
          - "application/wasm"
      - filter: router
        routes:
          - path_prefix: "/"
            cluster: backend
      - filter: load_balancer
        clusters:
          - name: backend
            endpoints:
              - "127.0.0.1:3000"

insecure_options:
  allow_private_endpoints: true # example proxies to local backends