# Endpoint Selector
#
# Selects an upstream endpoint from a trusted mutation
# source (e.g. external processing). Client-supplied header values
# are ignored to prevent SSRF. When no trusted value is
# present and required is false, the request falls
# through to the normal router/load_balancer pipeline.
#
# Usage:
#   cargo run -p praxis-proxy -- \
#     -c examples/configs/traffic-management/endpoint-selector.yaml
#
# Exercise:
#   # Without a trusted mutation source, falls through to default routing
#   curl http://localhost:8080/

listeners:
  - name: default
    address: "127.0.0.1:8080"
    filter_chains:
      - main

filter_chains:
  - name: main
    filters:
      - filter: endpoint_selector
        source_header: x-gateway-destination
        strip_header: true
        required: false
        connection:
          connection_timeout_ms: 1000
          total_connection_timeout_ms: 2000

      - 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
