Skip to content

agent-as-reverse-proxy example not updated for agent v3 + request host forwarding broken with agent v3 #6

@DCurci

Description

@DCurci

Description

The agent-as-reverse-proxy example appears to be outdated and has not been updated for agent v3 (latest version is v3.1.0). Additionally, request host forwarding as reverse proxy does not work correctly with agent v3 at least with HTTP/1.x backend protocol (max_http_version: "h1").

What changed between v2 and v3

In agent v2, host preservation was controlled in agent.yaml configuration file via:

proxies.preserve_host = true | false

In v3, according to the documentation, the equivalent setting is:

reverse_proxy.forward.request_host = (string)

The docs state: "If not specified, it will use the request hostname" — implying host forwarding should work by default. However, in practice the request host is not being forwarded correctly when running the agent-as-reverse-proxy example with agent v3.

Steps to reproduce

  1. Clone this forked repository: https://github.com/DCurci/docker-example
  2. Run the agent-as-reverse-proxy example
  3. Observe that the upstream receives the wrong Host header

The agent-as-reverse-proxy example has been modified for agent v3 providing a sample agent.yaml configuration file and a custom nginx.conf file to print the following received headers in the nginx logs:

  • Host
  • X-Forwarded-For
  • X-Forwarded-Host
  • X-Forwarded-Proto

When the agent-as-reverse-proxy example runs, in TRACE log level, a message like the following one is printed:

redirectionio-agent-1 | 2026-05-15T12:14:59.803301Z TRACE creating proxy service for peer: RedirectionIoHttpPeer { address: Host("nginx"), port: 80, tls: false, request_host: Some("nginx"), sni_host: Some("nginx"), identifier: "redirectionio-proxy/docker-reverse-proxy", allow_invalid_certificates: false, force_close: false, forward_header_strategy: Auto, request_timeout: Some(15s), response_timeout: Some(15s), body_size_limit: 16777216 }

where you can see: request_host: Some("nginx")

Observed behavior

  1. When invoking the agent reverse proxy (port: 8080) with:
curl 'http://127.0.0.1:8080/' -H 'Host: localhost' -H 'X-Forwarded-Host: www.example.com' -H 'X-Forwarded-For: 127.0.0.1' -H 'X-Forwarded-Proto: http'

the request host is always set as specified in reverse_proxy.forward.address (i.e. nginx) and the nginx log is:

... "GET / HTTP/1.1" 200 1234 "referer: -" "user-agent: curl/8.20.0" "host: nginx" "x-forwarded-for: 127.0.0.1, 172.21.0.1" "x-forwarded-host: www.example.com" "x-forwarded-proto: http"
  1. When invoking the nginx server directly (port: 80) with:
curl 'http://127.0.0.1:80/' -H 'Host: localhost' -H 'X-Forwarded-Host: www.example.com' -H 'X-Forwarded-For: 127.0.0.1' -H 'X-Forwarded-Proto: http'

the request host is correct (i.e. localhost) and the nginx log is:

... "GET / HTTP/1.1" 200 1234 "referer: -" "user-agent: curl/8.20.0" "host: localhost" "x-forwarded-for: 127.0.0.1" "x-forwarded-host: www.example.com" "x-forwarded-proto: http"

Expected behavior

The example should work with agent v3, and the request Host header should be forwarded to the upstream as documented. Otherwise agent v3 will not work with CDNs forwarding the request host header and an upstream server with several virtual hosts.

Environment

  • Agent version: v3.1.0 (latest)
  • Example: agent-as-reverse-proxy

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions