From e1f0af33022c2d3aac82a6b58ae959884b82237d Mon Sep 17 00:00:00 2001 From: nightcityblade Date: Thu, 13 Aug 2026 11:06:25 +0800 Subject: [PATCH] docs: clarify alpha upstream path syntax Signed-off-by: nightcityblade --- docs/docs/configuration/alpha_config.md | 2 +- pkg/apis/options/upstreams.go | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/docs/configuration/alpha_config.md b/docs/docs/configuration/alpha_config.md index 680741ba..36df0c1e 100644 --- a/docs/docs/configuration/alpha_config.md +++ b/docs/docs/configuration/alpha_config.md @@ -678,7 +678,7 @@ Requests will be proxied to this upstream if the path matches the request path. | Field | Type | Description | | ----- | ---- | ----------- | | `id` | _string_ | ID should be a unique identifier for the upstream.
This value is required for all upstreams. | -| `path` | _string_ | Path is used to map requests to the upstream server.
The closest match will take precedence and all Paths must be unique.
Path can also take a pattern when used with RewriteTarget.
Path segments can be captured and matched using regular experessions.
Eg:
- `^/foo$`: Match only the explicit path `/foo`
- `^/bar/$`: Match any path prefixed with `/bar/`
- `^/baz/(.*)$`: Match any path prefixed with `/baz` and capture the remaining path for use with RewriteTarget | +| `path` | _string_ | Path is used to map requests to the upstream server.
The closest match will take precedence and all Paths must be unique.
Without RewriteTarget, Path follows gorilla/mux route syntax.
Eg:
- `/foo`: Match only the explicit path `/foo`
- `/bar/`: Match any path prefixed with `/bar/`
- `/baz/{path:.*}`: Match any path prefixed with `/baz/`
When RewriteTarget is set, Path is treated as a regular expression.
Eg: `^/baz/(.*)$` matches any path prefixed with `/baz` and captures the
remaining path for use with RewriteTarget. | | `rewriteTarget` | _string_ | RewriteTarget allows users to rewrite the request path before it is sent to
the upstream server (for an HTTP/HTTPS upstream) or mapped to the filesystem
(for a `file:` upstream).
Use the Path to capture segments for reuse within the rewrite target.
Eg: With a Path of `^/baz/(.*)`, a RewriteTarget of `/foo/$1` would rewrite
the request `/baz/abc/123` to `/foo/abc/123` before proxying to the
upstream server. Or if the upstream were `file:///app`, a request for
`/baz/info.html` would return the contents of the file `/app/foo/info.html`. | | `uri` | _string_ | The URI of the upstream server. This may be an HTTP(S) server of a File
based URL. It may include a path, in which case all requests will be served
under that path.
Eg:
- http://localhost:8080
- https://service.localhost
- https://service.localhost/path
- file://host/path
If the URI's path is "/base" and the incoming request was for "/dir",
the upstream request will be for "/base/dir". | | `insecureSkipTLSVerify` | _bool_ | InsecureSkipTLSVerify will skip TLS verification of upstream HTTPS hosts.
This option is insecure and will allow potential Man-In-The-Middle attacks
between OAuth2 Proxy and the upstream server.
Defaults to false. | diff --git a/pkg/apis/options/upstreams.go b/pkg/apis/options/upstreams.go index 578ab454..9ededc28 100644 --- a/pkg/apis/options/upstreams.go +++ b/pkg/apis/options/upstreams.go @@ -62,12 +62,14 @@ type Upstream struct { // Path is used to map requests to the upstream server. // The closest match will take precedence and all Paths must be unique. - // Path can also take a pattern when used with RewriteTarget. - // Path segments can be captured and matched using regular experessions. + // Without RewriteTarget, Path follows gorilla/mux route syntax. // Eg: - // - `^/foo$`: Match only the explicit path `/foo` - // - `^/bar/$`: Match any path prefixed with `/bar/` - // - `^/baz/(.*)$`: Match any path prefixed with `/baz` and capture the remaining path for use with RewriteTarget + // - `/foo`: Match only the explicit path `/foo` + // - `/bar/`: Match any path prefixed with `/bar/` + // - `/baz/{path:.*}`: Match any path prefixed with `/baz/` + // When RewriteTarget is set, Path is treated as a regular expression. + // Eg: `^/baz/(.*)$` matches any path prefixed with `/baz` and captures the + // remaining path for use with RewriteTarget. Path string `yaml:"path,omitempty"` // RewriteTarget allows users to rewrite the request path before it is sent to