# Redirect
#
# Returns a 3xx redirect without contacting any upstream.
# Useful for scheme upgrades (HTTP to HTTPS), domain
# migrations, or path reorganization.
#
# The location template supports ${path} and ${query}
# placeholders from the original request URI.
#
# Usage:
#   cargo run -p praxis-proxy -- -c examples/configs/traffic-management/redirect.yaml
#   curl -v http://localhost:8080/some/path?q=1
#   curl -v http://localhost:8081/docs/guide?lang=en

listeners:
  - name: https_upgrade
    address: "127.0.0.1:8080"
    filter_chains:
      - https_upgrade

  - name: domain_migration
    address: "127.0.0.1:8081"
    filter_chains:
      - domain_migration

filter_chains:
  - name: https_upgrade
    filters:
      - filter: redirect
        status: 301
        location: "https://example.com${path}"

  - name: domain_migration
    filters:
      - filter: redirect
        status: 308
        location: "https://new.example.com${path}${query}"
