diff --git a/README.md b/README.md index 54b49ef66..56e84c074 100644 --- a/README.md +++ b/README.md @@ -123,7 +123,7 @@ spec: [(Back to top)](#table-of-contents) -See [Custom Resources](https://kubeshop.github.io/kusk-gateway/customresources/) for how to develop Kusk Gateway. +See [Custom Resources](https://kubeshop.github.io/kusk-gateway/customresources/) for more information on the Custom Resources that Kusk Gateway supports. ## Troubleshooting diff --git a/docs/extension.md b/docs/extension.md index 3cd2e7609..abdbf8f58 100644 --- a/docs/extension.md +++ b/docs/extension.md @@ -207,6 +207,28 @@ The path object contains the following properties to configure service endpoints | rewrite_regex.pattern | Regular expression to rewrite the URL | | rewrite_regex.substitution | Regular expression's substitution | +If a rewrite isn't specified then the upstream service will receive the request as is with any path still appended. + +#### Example + +We have a service `foo` with a single endpoint `/bar`. + +We configure Kusk Gateway to forward traffic to the `foo` service when it receives traffic on a path with the prefix `/foo`. + +![path rewrite example](img/rewrite-path-example.png) + +If we receive a request at `/foo/bar`, the request will be forwarded to the `foo` service. `foo` will throw a 404 error as it doesn't have a path `/foo/bar`. + +Therefore we must rewrite the path from `/foo/bar` to `/bar` before sending it onto the `foo` service. + +The following config extract will allow us to do this +``` +path: + # /foo/bar/... -> to upstream: /bar/... + rewrite: + pattern: "^/foo" + substitution: "" +``` ### qos The QoS objects contains the following properties to configure quality of service for endpoints: diff --git a/docs/img/rewrite-path-example.png b/docs/img/rewrite-path-example.png new file mode 100644 index 000000000..1c65ca377 Binary files /dev/null and b/docs/img/rewrite-path-example.png differ