Skip to content

Latest commit

 

History

History
243 lines (214 loc) · 28.3 KB

README.md

File metadata and controls

243 lines (214 loc) · 28.3 KB

Examples

Configuration examples organized by category.

Running an Example

cargo run -p praxis-proxy -- -c examples/configs/traffic-management/basic-reverse-proxy.yaml
curl http://localhost:8080/

Configs use local ports (3000, 3001, ...) for upstreams. For quick experiments without a real backend, use static_response (see static-response.yaml) or run Praxis with no config file for a built-in welcome page.

Quick Test Utilities

Echo server for testing without configuration:

cargo xtask echo
curl http://127.0.0.1:8080/

Debug mode runs examples with dev-friendly settings (debug logs, admin API on :9090, single-threaded):

cargo xtask debug examples/configs/security/guardrails-per-model.yaml

See Quickstart for full options.

Configs

Branching

File Description
conditional-skip-to.yaml Skips the remaining middleware for clean requests
conditional-terminal.yaml Short-circuits the pipeline when guardrails detects a dangerous request header
cross-chain-flat.yaml A listener references two chains: preprocessing and routing
multiple-branches.yaml Multiple branches on a single filter, evaluated in order
named-chain-ref.yaml A branch references a top-level chain by name instead of defining filters inline
nested-branches.yaml Branch filters that themselves contain branches, forming a multi-level decision tree
reentrance.yaml Loops back to a named filter up to N times
result-matchers.yaml Builds a deny-by-default JSON-RPC allowlist out of branch result matchers
unconditional-branch.yaml Always runs a utility chain before continuing the main pipeline

Observability

File Description
access-log-fields.yaml Logs only server errors with a lean field set
access-log-file-sink.yaml Writes NDJSON access log records directly to a file, bypassing the tracing subscriber
access-log-syslog.yaml Ships access log records to a syslog daemon as RFC 3164 messages, bypassing the tracing subscriber
access-log-template.yaml Renders a configurable text line for each request
access-logging.yaml Structured JSON logging with sampling; logs ~10% of requests. request_id ensures each log line has a correlation ID. access_log emits method, path, status, and timing
cloud-events-request-complete.yaml Publishes a bounded, best-effort CloudEvent when a request ends, including responses that abort after their headers are sent
cloud-events.yaml Publishes a bounded, best-effort CloudEvents 1.0 response event after a final bodyless response or response end-of-stream
errors-total.yaml Prometheus counter for proxy errors classified by cause, covering filter rejections, timeouts, unreachable upstreams and internal faults
grpc-access-log.yaml Logs how each gRPC call ended
grpc-health-check.yaml Probes upstream endpoints with grpc.health.v1.Health/Check instead of an HTTP GET
http-active-requests.yaml Prometheus gauge for HTTP requests currently in flight per listener
logging.yaml request_id — ensures every request has a correlation ID
metric-label-sets.yaml Selectively disables individual label dimensions on Prometheus metrics to bound total time-series cardinality
overload-gauges.yaml Publishes smoothed praxis_overload_pressure gauges for cgroup memory, anonymous resident memory, CPU stall time, connections, and file descriptors
process-logging.yaml Non-blocking process logs written to a file
route-templates.yaml Collapses dynamic path segments in the Prometheus route label into stable templates, so high-variety URLs share one series instead of widening cardinality
tcp-access-log.yaml Structured JSON logging of TCP connection events (connect and disconnect)
tcp-active-connections.yaml Prometheus gauge for TCP connections currently open per listener
tcp-byte-counters.yaml Prometheus counters for bytes forwarded over TCP connections in each direction, labeled by listener
tcp-connection-metrics.yaml Prometheus histogram for TCP connection duration
tcp-connections-total.yaml Prometheus counter for total accepted TCP connections per listener
tls-health-check.yaml Check upstream certificates with a TLS handshake or verify an HTTPS health endpoint with the experimental tls-health-check feature
trace-context.yaml W3C Trace Context header propagation
tracing-otlp.yaml Exports distributed tracing spans to an OpenTelemetry Collector via OTLP/gRPC
upstream-requests-total.yaml Prometheus counter for requests that reached an upstream endpoint, labeled by cluster, endpoint and status class

Operations

File Description
admin-interface.yaml Exposes separate admin API and health/metrics listeners
admin-kv-store.yaml Serves runtime key-value stores on the admin API for an application that embeds Praxis and registers the stores in code
container-default.yaml Default config for containerized deployments
drain-handoff.yaml Readiness-first SIGTERM handoff: /ready reports draining immediately while the listener keeps accepting for shutdown_drain_delay_secs, then closes existing HTTP/1 connections cleanly
file-descriptor-limits.yaml Size and protect the proxy's open file descriptor budget: pin the process limit, shed requests with 503 before descriptors run out, and close idle keep-alive clients and pooled upstream connections so they cannot pin descriptors
hot-reload.yaml Filter pipelines are swapped atomically at runtime when the config file changes
log-overrides.yaml Use runtime.log_overrides to raise or lower log verbosity for specific modules without flooding output from every subsystem
max-connections.yaml HTTP listeners return 503 with Retry-After: 1. TCP listeners close the socket immediately
multi-listener.yaml Demonstrates multiple HTTP listeners, each with its own filter pipeline
production-gateway.yaml Combines TLS, logging, timeouts, security headers, path routing, and load balancing

Payload Processing

File Description
body-size-limit-with-extraction.yaml Combines body_limits.max_buffer_bytes with json_body_field to enforce a buffering cap while still performing body-based routing
compression.yaml Enables transparent response compression using Pingora's built-in compression module
conditional-field-extraction.yaml Uses the condition system to apply json_body_field only on specific request paths
field-extraction-access-control.yaml Extracts the "tenant_id" field from the JSON request body and promotes it to a client-unspoofable X-Praxis-Tenant-Id header
grpc-web.yaml Lets a browser call a gRPC backend
json-body.yaml Rewrites a JSON request body with JSON Pointer extract, replace, add, and remove, and the response body with remove and extract
json-rpc.yaml Extracts JSON-RPC 2.0 envelope metadata from request bodies and promotes method, id, and kind to request headers
multi-field-extraction.yaml A single json_body_field filter extracts multiple top-level JSON fields into separate request headers in one pass
multi-listener-body-pipeline.yaml Three listeners with different field extraction and routing behavior
stream-buffer.yaml json_body_field inspects request body chunks as they arrive and defers upstream forwarding until the field is extracted (or end-of-stream)

Pipeline

File Description
default.yaml Built-in default config (static JSON on /)
branch-chains.yaml Filters write structured results to FilterResultSet
composed-chains.yaml Multiple named chains are composed per listener
conditional-filters.yaml Filters support conditions (request phase) and response_conditions (response phase) to gate execution
failure-mode.yaml Demonstrates open and closed failure handling for filters
grpc-condition.yaml The grpc condition predicate gates a filter on whether the request carries gRPC, classified from the content-type header alone (application/grpc, application/grpc+proto, application/grpc+json, or any other application/grpc+<codec>)
header-presence-condition.yaml The headers_present condition predicate gates a filter on whether headers are present, whatever their values
inherited-conditions.yaml A named filter chain declares one conditions: block that every filter in the chain inherits
iterative-request-router-circuit-breaker.yaml Demonstrates circuit breaker integration with the iterative request router
iterative-request-router-sequence.yaml Demonstrates sequential sub-request execution where each step completes before the next begins
route-on-promoted-header.yaml Classify a request in an early filter, promote the result to a reserved x-praxis-* header, and route on that header
selected-upstream-conditions.yaml Gate a filter on the application metadata the load balancer publishes when it selects an upstream

Protocols

File Description
grpc-http2-upstream.yaml Praxis proxies to upstreams over HTTP/1.1 by default. gRPC backends speak HTTP/2 only, and a call's outcome (grpc-status) arrives in response trailers, which no HTTP/1.1 leg can carry
mixed-protocol.yaml HTTP and TCP listeners run on a single server instance
tcp-consistent-hash.yaml TCP consistent-hash load balancing (client IP affinity)
tcp-least-connections.yaml TCP least-connections load balancing
tcp-proxy.yaml Bidirectional TCP forwarding
tcp-round-robin.yaml TCP round-robin load balancing across database replicas
tcp-timeouts.yaml TCP proxy with session and max duration timeouts. tcp_session_timeout_ms wraps the entire TCP forwarding session in a hard deadline, terminating connections after the threshold regardless of activity. tcp_max_duration_secs caps the total session duration in seconds
tcp-tls-mtls.yaml The proxy requires TCP clients to present a valid TLS certificate signed by the trusted CA
tcp-tls-termination.yaml TLS on the listener; plain TCP to the upstream backend
tls-cipher-suites.yaml Restrict accepted cipher suites per listener
tls-http-reencrypt.yaml HTTPS on the listener; TLS to the upstream backend
tls-mtls-both.yaml Client mTLS to the proxy (client cert required), and proxy mTLS to the upstream backend (proxy presents its own client certificate)
tls-mtls-listener-request.yaml The proxy requests a client certificate but does not require one
tls-mtls-listener.yaml The proxy requires clients to present a valid TLS certificate signed by the trusted CA
tls-mtls-spiffe.yaml The proxy authorizes a client at the TLS handshake by the SPIFFE ID in its X.509-SVID client certificate
tls-mtls-upstream.yaml Plain HTTP from clients; the proxy presents a client certificate to the upstream backend, which requires mutual TLS authentication
tls-multi-cert.yaml Multiple certificates on one listener; Praxis selects the certificate matching the client's SNI hostname
tls-sni-routing.yaml Routes TLS connections to different upstreams based on the Server Name Indication (SNI) hostname in the ClientHello
tls-termination.yaml HTTPS on the listener; plain HTTP to the backend
tls-verify-disabled.yaml Plain HTTP listener; TLS to the upstream with certificate verification disabled
tls-version-constraint.yaml Restrict accepted TLS versions via min_version
upstream-ca-file.yaml Sets a trusted CA bundle for all upstream TLS connections via runtime.upstream_ca_file
upstream-tls.yaml Plain HTTP on the listener; TLS to the upstream
websocket.yaml HTTP listener that transparently proxies WebSocket upgrade requests

Security

File Description
basic-auth.yaml Authenticate requests using HTTP Basic Authentication (RFC 7617)
cors.yaml Spec-compliant CORS filter with preflight handling, origin validation, and credential support
credential-injection-env-vars.yaml Injects per-service API credentials read from environment variables, so no secret is written into the config
credential-injection.yaml Injects per-cluster API credentials into upstream requests
csrf.yaml Cross-site request forgery protection via origin validation
downstream-read-timeout.yaml Protects against slow client attacks by limiting how long the proxy waits for data from downstream clients
forward-proxy-ip-acl.yaml Forward proxy with no destination allowlist: any destination other than a private or reserved address is reachable, and egress control rests on the ip_acl filter gating which clients may open tunnels
forward-proxy.yaml HTTP listener that doubles as an egress gateway for clients configured with HTTPS_PROXY: CONNECT tunnels reach only the destinations in allow_destinations
forwarded-headers.yaml Injects X-Forwarded-For, X-Forwarded-Proto, and X-Forwarded-Host into upstream requests
guardrails-per-model.yaml Runs body-inspecting guardrails only for a model selected from the request body
guardrails.yaml Reject requests that match header or body inspection rules
ip-acl.yaml Allow or deny requests by source IP/CIDR
peer-identity-trust.yaml Validates downstream mTLS peer identity against a set of trusted peers
policy-admission.yaml The policy filter rate-limits and authenticates from the request head, before any filter reads the body, even when a body-reading filter comes first in the chain
policy-api-key.yaml Authenticates generic HTTP traffic with API keys using the Praxis Policy Engine
policy-assertions.yaml Projects policy-derived identity into request headers and removes credentials that should not reach the upstream
policy-context.yaml Demonstrates the host-supplied context surface: context_headers maps reserved-prefix HTTP headers to agent / framework extension fields so APL rules can reference them; context_meta stamps operator-defined scope, tags, and properties onto every policy evaluation
policy-http.yaml Generic-HTTP authorization for non-MCP traffic using the Praxis Policy Engine
policy-jwt-fips.yaml Authenticates generic HTTP traffic with asymmetric JWTs, verified through the system OpenSSL FIPS provider
policy-llm-input.yaml Denies inference requests by what they ask of the model, using the normalized llm.input.* facts the proxy derives from the request body: offered tools, tool choice, completion cap, and ordered instructions
policy-llm.yaml Authorizes body-addressed inference requests against llm: policy routes
policy-query-credential.yaml Authenticates requests whose API key arrives in the query string, as WebSocket and SSE clients that cannot set headers send it
policy-rate-limit.yaml Rate limits requests in two stages with the Praxis Policy Engine's in-process limiter (ratelimit/limitador, experimental)
policy.yaml Embeds the Praxis Policy Engine in-process to enforce multi-source identity, APL route policy, RFC 8693 OAuth 2.0 token exchange, field redaction, session taint, audit emission, and (under body_access: read_write) request / response body rewriting

Traffic Management

File Description
authority-from-endpoint.yaml Sends each upstream request's Host header as the address of the endpoint the load balancer picked, so one cluster can front endpoints that answer to different hostnames
authority-override.yaml Demonstrates overriding the HTTP Host header sent to a specific upstream cluster, including requests received over HTTP/2
basic-reverse-proxy.yaml Minimal config: one listener, one upstream, default filter chain
bound-upstream-condition.yaml Gates a filter on the logical upstream the router bound for the request
bound-upstream-dispatch.yaml Selects an upstream endpoint straight from the logical binding, with no second router
canary-routing.yaml Sends ~10% of traffic to a canary backend while the stable backend handles the remaining ~90%
circuit-breaker.yaml Prevents cascading failures by tracking consecutive upstream errors per cluster
cluster-application-metadata.yaml Tags an upstream cluster with opaque application metadata that consuming filters interpret
cluster-base-path.yaml Prepends a path to the upstream request for the cluster the load balancer selected, so one gateway can front several upstreams that each serve the same API under their own prefix
cluster-max-connections.yaml Caps the concurrent in-flight requests the load balancer will send to one cluster, so a single slow upstream cannot consume all available capacity
cluster-references.yaml An inline load-balancer cluster that shares its name with a top-level declaration may omit its endpoints: validation fills them in from the declaration, so the routed addresses and the health-checked addresses cannot drift apart
endpoint-selector.yaml Selects an upstream endpoint from a trusted mutation source (e.g. external processing)
grpc-detection.yaml Detects gRPC requests from the content-type header and promotes the variant to filter metadata and results
grpc-timeout.yaml Honours the grpc-timeout request header as a real deadline
head-classifier.yaml Classifies each request from its head (path) and promotes the class as a reserved x-praxis-head-class header that the router matches to pick an upstream
health-checks.yaml Per-cluster health checks probe endpoints on a timer and remove unhealthy backends from the load balancer rotation
hedged-requests.yaml Races one idempotent request across two endpoints and returns the first 2xx, 3xx, or 4xx response
hostname-upstream.yaml Demonstrates using DNS hostnames instead of IP addresses for upstream endpoints
hosts.yaml One listener serves multiple domains
http-query.yaml Forwards body-bearing QUERY requests with bounded retries and explicit browser CORS and CSRF settings for a read-only query resource
iterative-request-router-failover.yaml Demonstrates provider failover using the iterative_request_router filter
iterative-request-router-origin-failover.yaml Demonstrates origin-aware failover: only an upstream 429 (rate limit) triggers the fallback
least-connections.yaml Routes each request to the backend with the fewest in-flight requests
maglev.yaml Pins a user's requests to one backend by hashing a request header through a Maglev lookup table
p2c.yaml Samples two random endpoints and picks the one with fewer in-flight requests
path-based-routing.yaml Routes by URL path prefix
priority-lb.yaml Defines primary and failover endpoint tiers
random.yaml Selects an upstream endpoint at random, weighted by endpoint weight
rate-limiting-shadow.yaml Observe a rate limit before enforcing it
rate-limiting.yaml Token bucket rate limiter with per-IP or global modes
redirect.yaml Returns a 3xx redirect without contacting any upstream
retry-policy.yaml Retries connection failures and resets up to two times per request, with exponential backoff between attempts
ring-hash.yaml Routes requests to a stable backend by hashing a configurable request header through a sorted virtual-node ring
round-robin.yaml Default strategy
session-affinity.yaml Hashes a request header to pin a user's requests to one backend
slow-start.yaml Ramp newly added and recovered endpoints up to their configured weight
static-response.yaml Returns a fixed response without contacting any upstream
sticky-sessions.yaml Pins clients to a specific backend across requests
subset-lb.yaml Filters endpoints by metadata labels and applies an inner strategy within the matching subset
timeout.yaml Returns 504 if the upstream takes longer than timeout_ms to respond
trusted-private-endpoints.yaml Lets one hostname endpoint resolve into private space, such as a Kubernetes Service name resolving to its ClusterIP
weighted-load-balancing.yaml Traffic split proportional to per-endpoint weights
zone-aware.yaml Prefers same-zone endpoints to reduce cross-zone network costs and latency

Transformation

File Description
grpc-status-errors.yaml Answers proxy-generated errors in the shape gRPC clients expect. gRPC carries a call's outcome in a grpc-status header on an HTTP 200, not in the HTTP status, so a client that meets Praxis's own 403 or 502 sees a bare transport failure with no usable status
header-manipulation.yaml Add, overwrite, and remove headers on requests and responses
path-rewriting.yaml Rewrite selected request paths after routing and before forwarding
url-rewriting-preserve.yaml Drop every query param except the ones listed (allowlist)
url-rewriting.yaml Regex-based path transformation and query string manipulation