Merge pull request #3174 from Shopify/rewrite-regex
Generalize Rewrite Block Creation and Deprecate AddBaseUrl (not backwards compatible)
This commit is contained in:
commit
71cc6df74f
11 changed files with 71 additions and 396 deletions
|
|
@ -57,11 +57,11 @@ spec:
|
|||
paths:
|
||||
- path: /foo/bar
|
||||
backend:
|
||||
serviceName: test
|
||||
serviceName: service1
|
||||
servicePort: 80
|
||||
- path: /foo/bar/
|
||||
backend:
|
||||
serviceName: test
|
||||
serviceName: service2
|
||||
servicePort: 80
|
||||
```
|
||||
|
||||
|
|
@ -79,14 +79,14 @@ spec:
|
|||
paths:
|
||||
- path: /foo/bar/.+
|
||||
backend:
|
||||
serviceName: test
|
||||
serviceName: service3
|
||||
servicePort: 80
|
||||
```
|
||||
|
||||
The ingress controller would define the following location blocks, in order of descending length, within the NGINX template for the `test.com` server:
|
||||
|
||||
```txt
|
||||
location ~* "^/foo/bar/.+\/?(?<baseuri>.*)" {
|
||||
location ~* ^/foo/bar/.+ {
|
||||
...
|
||||
}
|
||||
|
||||
|
|
@ -101,13 +101,12 @@ location ~* "^/foo/bar" {
|
|||
|
||||
The following request URI's would match the corresponding location blocks:
|
||||
|
||||
- `test.com/foo/bar/1` matches `~* "^/foo/bar/.+\/?(?<baseuri>.*)"`
|
||||
- `test.com/foo/bar/` matches `~* "^/foo/bar/"`
|
||||
- `test.com/foo/bar` matches `~* "^/foo/bar"`
|
||||
- `test.com/foo/bar/1` matches `~* ^/foo/bar/.+` and will go to service 3.
|
||||
- `test.com/foo/bar/` matches `~* ^/foo/bar/` and will go to service 2.
|
||||
- `test.com/foo/bar` matches `~* ^/foo/bar` and will go to service 1.
|
||||
|
||||
**IMPORTANT NOTES**:
|
||||
|
||||
- paths created under the `rewrite-ingress` are sorted before `\/?(?<baseuri>.*)` is appended. For example if the path defined within `test-ingress-2` was `/foo/.+` then the location block for `^/foo/.+\/?(?<baseuri>.*)` would be the LAST block listed.
|
||||
- If the `use-regex` OR `rewrite-target` annotation is used on any Ingress for a given host, then the case insensitive regular expression [location modifier](https://nginx.org/en/docs/http/ngx_http_core_module.html#location) will be enforced on ALL paths for a given host regardless of what Ingress they are defined on.
|
||||
|
||||
## Warning
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue