networking: add prefix_rewrite and uri_regex_rewrite to HTTPRedirect#3708
Open
liamawhite wants to merge 3 commits into
Open
networking: add prefix_rewrite and uri_regex_rewrite to HTTPRedirect#3708liamawhite wants to merge 3 commits into
liamawhite wants to merge 3 commits into
Conversation
Extends HTTPRedirect to support prefix-aware path manipulation on redirect responses, exposing Envoy's existing prefix_rewrite and regex_rewrite capabilities in RedirectAction. Previously, HTTPRedirect.uri replaced the entire path regardless of the route match type. This adds two new mutually-exclusive fields: - prefix_rewrite: replaces the matched route prefix with the given value, enabling /foo/bar -> /baz/bar style redirects - uri_regex_rewrite: rewrites the path using RE2 regex with capture group substitution for complex transformations Both are mutually exclusive with the existing uri field. Validation is enforced in the istio/istio control plane.
|
🤔 🐛 You appear to be fixing a bug in Go code, yet your PR doesn't include updates to any test files. Did you forget to add a test? Courtesy of your friendly test nag. |
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.
Summary
HTTPRedirect.uriperforms a full path replacement and has no prefix-aware variant. Envoy'sRedirectActionhas supportedprefix_rewriteandregex_rewritefor years, but Istio has never exposed them, making it impossible to perform redirects that preserve the path suffix (e.g.example.com/foo/bar→foo.example.com/bar).This was requested in istio/istio#47500, istio/istio#47777, and istio/istio#52521, all of which were closed as stale.
This PR adds two new fields to
HTTPRedirectinside aoneof path_rewrite_specifier:prefix_rewrite— replaces the matched route prefix, leaving the rest of the path intact. The route must use a prefix URI match.uri_regex_rewrite— RE2 regex rewrite with capture group substitution (reuses the existingRegexRewritemessage).Both are mutually exclusive with the existing
urifield (enforced by validation in istio/istio). The legacyurifield is unchanged.Examples
Strip a prefix and change host (
/foo/bar→foo.example.com/bar):Replace a prefix (
/foo/bar→/baz/bar):Regex rewrite (
/api/v1/users→/users):Related