envoyproxy / envoyproxy/gateway

Cannot match / and rewrite prefix to the original path

Open
#6,764 9 comments 2 reactions 0 assignees View on GitHub
stale triage
Dominant language
Go
Stars
3k
Forks
864
Avg merge
2d 2h
Merged PRs (30d)
140

Description

*Description*:
When using an HTTPRoute in Envoy Gateway with a PathPrefix match of /, there is no way to prepend a static prefix to the path while preserving the original path content.
For example, with a desired rewrite rule like:
Incoming path | Desired rewritten path
-- | --
/abc | /prefix/abc
/foo/bar | /prefix/foo/bar
/anything | /prefix/anything

*Repro steps*:
1. Create an HTTPRoute with:
```
filters:
- type: URLRewrite
urlRewrite:
path:
replacePrefixMatch: /prefix/
type: ReplacePrefixMatch
matches:
- path:
type: PathPrefix
value: /
```
2) curl -vk https://example.io/test:
```
{
"path": "/prefixtest",
"host": "example.io",
"method": "GET",
"proto": "HTTP/1.1",
"headers": {
"Accept": [
"*/*"
]
}
```

Envoy RouteConfig:
```
{
"match": {
"prefix": "/"
},
"route": {
"cluster": "httproute/default/example-route/rule/0",
"prefix_rewrite": "/prefix",
"upgrade_configs": [
{
"upgrade_type": "websocket"
}
]
},
```

It seems we can get rid of the suffix trim [here](https://github.com/envoyproxy/gateway/blob/main/internal/xds/translator/route.go#L476).

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.