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.
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.
#
# Usage:
# cargo run -p praxis-proxy -- -c examples/configs/traffic-management/hostname-upstream.yaml
#
# curl http://localhost:8080/
#
# The request is forwarded to the backend resolved from the
# hostname endpoint. Because a hostname can be rebound between
# config load and connection time, a resolved private or reserved
# address is refused unless insecure_options.allow_private_upstreams
# is set - which this example needs, since "localhost" resolves to
# loopback.
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