Hosts

One listener serves multiple domains

Category: Practical
Task: One listener serves multiple domains

Prerequisites: The product runtime and any backend services referenced by this configuration.

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.

# Virtual Host Routing (Host-Based Routing)
#
# One listener serves multiple domains. The router matches on both the
# Host header and URL path prefix. Longest prefix wins; among equal-length
# prefixes, declaration order breaks ties. Place host-specific routes
# before catch-all routes.
#
#   api.example.com  →  api cluster
#   www.example.com  →  web cluster
#   (any other host) →  default cluster
#
listeners:
  - name: default
    address: "127.0.0.1:8080"
    filter_chains:
      - main

filter_chains:
  - name: main
    filters:
      - filter: router
        routes:
          - path_prefix: "/"
            host: "api.example.com"
            cluster: api

          - path_prefix: "/"
            host: "www.example.com"
            cluster: web

          # Catch-all
          - path_prefix: "/"
            cluster: default

      - filter: load_balancer
        clusters:
          - name: api
            endpoints:
              - "127.0.0.1:3001"
              - "127.0.0.1:3002"

          - name: web
            endpoints:
              - "127.0.0.1:4000"

          - name: default
            endpoints:
              - "127.0.0.1:5000"

insecure_options:
  allow_private_endpoints: true # example proxies to local backends