Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gateway-api: support removing path prefix #47254

Merged
merged 2 commits into from
Oct 13, 2023

Conversation

dddddai
Copy link
Member

@dddddai dddddai commented Oct 9, 2023

Please provide a description of this PR:
Fixes #47153

We can use RegexRewrite to implement this

@dddddai dddddai requested review from a team as code owners October 9, 2023 09:25
@istio-policy-bot istio-policy-bot added area/networking release-notes-none Indicates a PR that does not require release notes. labels Oct 9, 2023
@istio-testing istio-testing added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 9, 2023
action.PrefixRewrite = uri
if model.UseGatewaySemantics(vs) && uri == "/" {
// remove the prefix
action.RegexRewrite = &matcher.RegexMatchAndSubstitute{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK this is the same case as cilium/cilium#28294 tries to solve, but they do it differently. We should probably find the best way and make sure implementations are aligned.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think cilium/cilium#28294 is correct:

route.Route.RegexRewrite = &envoy_type_matcher_v3.RegexMatchAndSubstitute{
	Pattern: &envoy_type_matcher_v3.RegexMatcher{
		Regex: "^" + httpRoute.PathMatch.Prefix,
	},
	Substitution: "",
}

It does not handle the case where the entire path is removed. In this case we must set the URI to /. Please see https://www.rfc-editor.org/rfc/rfc9112.html#section-3.2.1-2.

If the target URI's path component is empty, the client MUST send "/" as the path within the origin-form of request-target.

If I have a RegexRewrite like:

regexRewrite:
  pattern:
    regex: ^/foo
  substitution: ""

I will get 502 when accessing /foo

I will probably send a patch to cilium to fix that

@istio-testing istio-testing merged commit 3e2c1cb into istio:master Oct 13, 2023
28 checks passed
@dddddai dddddai deleted the uri-rewrite branch October 14, 2023 06:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/networking release-notes-none Indicates a PR that does not require release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HTTPRoute: unable to remove path prefix via URLRewrite
4 participants