Examples

Body Size Limit With Extraction

Combines body_limits.max_buffer_bytes with json_body_field to enforce a buffering cap while still performing body-based routing

Praxis v0.8.0 2 min read

Category: Practical
Task: Combines body_limits.max_buffer_bytes with json_body_field to enforce a buffering cap while still performing body-based routing

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

Run it: Use ghcr.io/praxis-proxy/praxis:0.8.0 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.

# Body Size Limit with Field Extraction
#
# Combines body_limits.max_buffer_bytes with json_body_field to
# enforce a buffering cap while still performing
# body-based routing. Requests exceeding the limit receive
# 413 (Payload Too Large) before any extraction occurs.
#
# The buffering cap defaults to 64 MiB; this example lowers it to 1 KiB.
# Raise max_buffer_bytes, max_request_bytes, and the filter max_body_bytes
# together when intentionally accepting larger buffered requests.
#
listeners:
  - name: gateway
    address: "0.0.0.0:8080" # dev value; binds all interfaces
    filter_chains:
      - extract-model
      - routing

filter_chains:
  - name: extract-model
    filters:
      - filter: json_body_field
        field: model
        header: X-Model

  - name: routing
    filters:
      - filter: router
        routes:
          - path_prefix: "/"
            cluster: backend
      - filter: load_balancer
        clusters:
          - name: backend
            endpoints:
              - "127.0.0.1:3000"

# The 1 KiB buffering cap is stricter than the 2 KiB transfer limit.
# A 1025-byte request fails the buffering cap before extraction.
body_limits:
  max_buffer_bytes: 1024
  max_request_bytes: 2048

insecure_options:
  allow_private_endpoints: true # example proxies to local backends