Skip to content

router: add auto_host_rewrite support to RequestMirrorPolicy#44450

Open
derekargueta wants to merge 3 commits intoenvoyproxy:mainfrom
derekargueta:dargueta-mirror-auto-host-rewrite
Open

router: add auto_host_rewrite support to RequestMirrorPolicy#44450
derekargueta wants to merge 3 commits intoenvoyproxy:mainfrom
derekargueta:dargueta-mirror-auto-host-rewrite

Conversation

@derekargueta
Copy link
Copy Markdown
Member

@derekargueta derekargueta commented Apr 14, 2026

Fixes #9326.

The issue has been open since 2020. When a route uses both request_mirror_policy and auto_host_rewrite, the mirrored request gets the wrong Host header because the shadow is dispatched before the main request's upstream connection is established (and thus before auto_host_rewrite has a chance to fire). The discussion in the issue thread converged on adding auto_host_rewrite directly to RequestMirrorPolicy so it can be applied independently by the shadow writer.

Risk Level: low
Testing: unit tests
Docs Changes: done
Release Notes: done
Platform Specific Features: no

Adds a new `auto_host_rewrite` field to `RequestMirrorPolicy` so that
mirrored requests can have their Host header rewritten to the upstream
hostname selected by the shadow cluster's load balancer. This mirrors
the existing `auto_host_rewrite` behavior on the main route.

Previously, mirror policies only supported `host_rewrite_literal` for
host manipulation. When `auto_host_rewrite` is set, the `-shadow`
suffix append is implicitly disabled (same behavior as
`host_rewrite_literal`). If the selected upstream host has no hostname
(e.g. a STATIC cluster), the header is left unchanged.

Fixes envoyproxy#9326

Signed-off-by: Derek Argueta <dereka@airbnb.com>
Signed-off-by: Derek Argueta <derek.argueta@airbnb.com>
@repokitteh-read-only
Copy link
Copy Markdown

As a reminder, PRs marked as draft will not be automatically assigned reviewers,
or be handled by maintainer-oncall triage.

Please mark your PR as ready when you want it to be reviewed!

🐱

Caused by: #44450 was opened by derekargueta.

see: more, trace.

Signed-off-by: Derek Argueta <derek.argueta@airbnb.com>
@derekargueta
Copy link
Copy Markdown
Member Author

Both failures in Envoy/Checks appear to be pre-existing flakes unrelated to this PR. The tsan failures are in buffer_accounting_integration_test and load_stats_integration_test, and the compile_time_options failure is a 1/4 flake in on_demand_integration_test. None of these touch the router or shadow policy code changed here.

@derekargueta derekargueta marked this pull request as ready for review April 15, 2026 04:50
@repokitteh-read-only
Copy link
Copy Markdown

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to (api/envoy/|docs/root/api-docs/).
envoyproxy/api-shepherds assignee is @adisuissa
CC @envoyproxy/api-watchers: FYI only for changes made to (api/envoy/|docs/root/api-docs/).

🐱

Caused by: #44450 was ready_for_review by derekargueta.

see: more, trace.

Signed-off-by: Derek Argueta <derek.argueta@airbnb.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mirrored request with host rewrite has wrong Host header

3 participants