Forwarding Rules

Route requests to different configurations based on matching criteria

Overview

Forwarding rules route requests to different origin configurations based on matching criteria. When a request matches a forwarding rule, it is handled by the target configuration instead of the current origin's action. This enables hostname-based routing, path-based microservice routing, and dynamic request distribution.

Capabilities

  • Route to different hostname configurations based on path, headers, IP, or expressions
  • Inline origin configs via the origin field for self-contained routing
  • Header, path, method, and IP-based matching using the standard rules system
  • Config inheritance from parent origin
  • Multiple forwarding rules evaluated in order (first match wins)

Example

Route API requests to different backend services by path:

proxy:
  http_bind_port: 8080

origins:
  "api.example.com":
    forward_rules:
      - hostname: users-service
        rules:
          - path:
              prefix: /api/users
      - hostname: orders-service
        rules:
          - path:
              prefix: /api/orders
    action:
      type: static
      status_code: 404
      body: Not Found

Test it:

curl -H "Host: api.example.com" http://localhost:8080/