feat(translator): make append_x_forwarded_host configurable in HTTPRouteFilter#8527
Open
rborale5 wants to merge 7 commits intoenvoyproxy:mainfrom
Open
feat(translator): make append_x_forwarded_host configurable in HTTPRouteFilter#8527rborale5 wants to merge 7 commits intoenvoyproxy:mainfrom
rborale5 wants to merge 7 commits intoenvoyproxy:mainfrom
Conversation
…Filter Add appendXForwardedHost field to HTTPURLRewriteFilter to allow users to control whether the original Host header is appended to X-Forwarded-Host when hostname rewriting is configured. Defaults to true for backward compatibility. Fixes envoyproxy#8386 Signed-off-by: rborale5 <rborale5@gmail.com>
✅ Deploy Preview for cerulean-figolla-1f9435 canceled.
|
Signed-off-by: rborale5 <rborale5@gmail.com>
af02b5e to
d1c0df7
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8527 +/- ##
==========================================
- Coverage 74.13% 74.11% -0.03%
==========================================
Files 242 242
Lines 37669 37674 +5
==========================================
- Hits 27925 27921 -4
- Misses 7787 7795 +8
- Partials 1957 1958 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…name rewrite Add a test case where appendXForwardedHost is set without any hostname or path rewrite, covering the nil-URLRewrite initialization branch in filters.go (lines 893-894) that was previously uncovered. Signed-off-by: rborale5 <rborale5@gmail.com> Made-with: Cursor
cbba9a8 to
ae1454b
Compare
Signed-off-by: rborale5 <rborale5@gmail.com>
0aba71c to
535d880
Compare
zirain
approved these changes
Mar 18, 2026
Member
|
@rborale5 unneed to rebase too often, the first time comtribute need approval to kick CI. let's wait for review from another maintainer(need 2 for API changes.) |
Author
|
Got it @zirain, thanks. |
arkodg
reviewed
Mar 23, 2026
| } | ||
| } | ||
|
|
||
| if hrf.Spec.URLRewrite.AppendXForwardedHost != nil { |
Contributor
There was a problem hiding this comment.
should this live next to other hrf.Spec.URLRewrite logic, or is this intentionally chosen so its also applied to native route filter URLRewrite logic ?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
feat(translator): make append_x_forwarded_host configurable in HTTPRouteFilter
What this PR does / why we need it:
Problem
Currently, Envoy Gateway hardcodes
append_x_forwarded_host: truewhen hostname rewriting is configured viaHTTPRouteFilter, with no way to disable it. In some scenarios, users need to prevent the originalHostheader from being leaked to backend services via theX-Forwarded-Hostheader — for example, when the upstream misinterprets it, when a custom tracking mechanism is in place, or for security policies that restrict header forwarding.Code reference: https://github.com/envoyproxy/gateway/blob/main/internal/xds/translator/route.go#L582
Solution
Added a new optional
appendXForwardedHostfield to theHTTPURLRewriteFilterin theHTTPRouteFilterCRD. The field defaults totruewhen unset, preserving full backward compatibility.Changes
AppendXForwardedHost *boolfield toHTTPURLRewriteFilterAPI type (api/v1alpha1/httproutefilter_types.go)AppendXForwardedHost *boolfield to the IRURLRewritestruct (internal/ir/xds.go)internal/gatewayapi/filters.go)append_x_forwarded_hostinstead of hardcodingtrue(internal/xds/translator/route.go)make manifestsmake generatesite/content/en/latest/tasks/traffic/http-urlrewrite.mdrelease-notes/current.yamlTesting
httproute-with-urlrewrite-hostname-filter-append-x-forwarded-host.in/out.yaml) — teststrueandfalsepropagation to IRhttp-route-rewrite-url-host-no-append-x-forwarded-host) — tests IR-to-xDS translation fortrue,false, and default (nil → true)TestBuildXdsURLRewriteAction_AppendXForwardedHostinroute_test.go— directly tests nil, true, and false caseshttproutefilter_test.go— verifies Kubernetes accepts the CRD with the new fieldWhich issue(s) this PR fixes:
Fixes #8386
Release Notes: Yes