Hostname Upstream

Demonstrates using DNS hostnames instead of IP addresses for upstream endpoints

Category: Practical
Task: Route requests by hostname

Prerequisites: Praxis runtime; HTTP backends for the configured hostnames

Expected outcome: The request hostname selects the configured upstream.

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.

# Hostname Upstream Endpoints
#
# Demonstrates using DNS hostnames instead of IP addresses for
# upstream endpoints. The proxy resolves hostnames to IP addresses
# at connection time, preferring IPv4 when multiple records exist.
#
listeners:
  - name: default
    address: "0.0.0.0:8080"
    filter_chains: [main]

filter_chains:
  - name: main
    filters:
      - filter: router
        routes:
          - path_prefix: "/"
            cluster: backend
      - filter: load_balancer
        clusters:
          - name: backend
            endpoints:
              - "localhost:9000"

insecure_options:
  allow_private_endpoints: true # example proxies to local backends
  allow_private_upstreams: true # "localhost" resolves to loopback at connection time