# TLS Multi-Certificate SNI
#
# Multiple certificates on one listener; Praxis selects the
# certificate matching the client's SNI hostname. The entry
# with `default: true` is the fallback for unmatched SNI.
#
#   Client -> TLS(api.example.com) -> Praxis :8443 -> HTTP -> Backend :3000
#   Client -> TLS(web.example.com) -> Praxis :8443 -> HTTP -> Backend :3000
#   Client -> TLS(other)           -> Praxis :8443 -> HTTP -> Backend :3000
#
# Usage:
#   cargo run -p praxis-proxy -- -c examples/configs/protocols/tls-multi-cert.yaml
#   curl --resolve api.example.com:8443:127.0.0.1 https://api.example.com:8443/
#   curl --resolve web.example.com:8443:127.0.0.1 https://web.example.com:8443/

listeners:
  - name: secure
    address: "127.0.0.1:8443"
    filter_chains:
      - main
    tls:
      certificates:
        - cert_path: /etc/ssl/certs/api.pem
          key_path: /etc/ssl/private/api-key.pem
          server_names:
            - api.example.com

        - cert_path: /etc/ssl/certs/web.pem
          key_path: /etc/ssl/private/web-key.pem
          server_names:
            - web.example.com
            - www.example.com

        - cert_path: /etc/ssl/certs/default.pem
          key_path: /etc/ssl/private/default-key.pem
          default: true

filter_chains:
  - name: main
    filters:
      - 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
