Stream Buffer
json_body_field inspects request body chunks as they arrive and defers upstream forwarding until the field is extracted (or end-of-stream)
Category: Practical
Task: json_body_field inspects request body chunks as they arrive and defers upstream forwarding until the field is extracted (or end-of-stream)
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.
# Stream-Buffer Body Inspection with Action-Based Routing
#
# json_body_field inspects request body chunks as they arrive
# and defers upstream forwarding until the field is extracted
# (or end-of-stream). The extracted value is promoted to a
# request header, which the router then matches on to select
# the correct backend cluster.
#
listeners:
- name: web
address: "0.0.0.0:8080" # dev value; binds all interfaces
filter_chains:
- body-inspection
- routing
filter_chains:
# Extract the "action" field from the JSON body and promote
# it to the X-Action request header. StreamBuffer mode
# accumulates chunks and defers forwarding until extraction
# completes.
- name: body-inspection
filters:
- filter: json_body_field
field: action
header: X-Action
# Route based on the promoted X-Action header.
- name: routing
filters:
- filter: router
routes:
- path_prefix: "/"
headers:
x-action: "process"
cluster: processor
- path_prefix: "/"
headers:
x-action: "validate"
cluster: validator
- path_prefix: "/"
cluster: default
- filter: load_balancer
clusters:
- name: processor
endpoints:
- "127.0.0.1:3001"
- "127.0.0.1:3002"
- name: validator
endpoints:
- "127.0.0.1:3003"
- name: default
endpoints:
- "127.0.0.1:3000"
# Global body size ceiling (10 MB).
body_limits:
max_request_bytes: 10485760
insecure_options:
allow_private_endpoints: true # example proxies to local backends