Skip to content

Commit

Permalink
Merge pull request #3271 from hchenxa/hchenxa
Browse files Browse the repository at this point in the history
the sample ingress spec error
  • Loading branch information
k8s-ci-robot authored Oct 19, 2018
2 parents ad89a93 + 32b95be commit 222270a
Showing 1 changed file with 48 additions and 48 deletions.
96 changes: 48 additions & 48 deletions docs/user-guide/ingress-path-matching.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@ kind: Ingress
metadata:
name: test-ingress
annotations:
nginx.ingress.kubernetes.io/use-regex: true
nginx.ingress.kubernetes.io/use-regex: "true"
spec:
host: test.com
rules:
- http:
paths:
- path: /foo/.*
backend:
serviceName: test
servicePort: 80
- host: test.com
http:
paths:
- path: /foo/.*
backend:
serviceName: test
servicePort: 80
```
The preceding ingress definition would translate to the following location block within the NGINX configuration for the `test.com` server:

```txt
location ~* ^/foo/.* {
location ~* "^/foo/.*" {
...
}
```
Expand All @@ -48,18 +48,18 @@ kind: Ingress
metadata:
name: test-ingress-1
spec:
host: test.com
rules:
- http:
paths:
- path: /foo/bar
backend:
serviceName: test
servicePort: 80
- path: /foo/bar/
backend:
serviceName: test
servicePort: 80
- host: test.com
http:
paths:
- path: /foo/bar
backend:
serviceName: test
servicePort: 80
- path: /foo/bar/
backend:
serviceName: test
servicePort: 80
```

```yaml
Expand All @@ -70,37 +70,37 @@ metadata:
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
host: test.com
rules:
- http:
paths:
- path: /foo/bar/.+
backend:
serviceName: test
servicePort: 80
- host: test.com
http:
paths:
- path: /foo/bar/.+
backend:
serviceName: test
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/.+\/?(?<baseuri>.*)" {
...
}
location ~* ^/foo/bar/ {
location ~* "^/foo/bar/" {
...
}
location ~* ^/foo/bar {
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/.+\/?(?<baseuri>.*)"`
- `test.com/foo/bar/` matches `~* "^/foo/bar/"`
- `test.com/foo/bar` matches `~* "^/foo/bar"`

**IMPORTANT NOTES**:

Expand All @@ -121,32 +121,32 @@ Let the following ingress be defined:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: test-ingress-1
name: test-ingress-3
annotations:
nginx.ingress.kubernetes.io/use-regex: true
nginx.ingress.kubernetes.io/use-regex: "true"
spec:
host: test.com
rules:
- http:
paths:
- path: /foo/bar/bar
backend:
serviceName: test
servicePort: 80
- path: /foo/bar/[A-Z0-9]{3}
backend:
serviceName: test
servicePort: 80
- host: test.com
http:
paths:
- path: /foo/bar/bar
backend:
serviceName: test
servicePort: 80
- path: /foo/bar/[A-Z0-9]{3}
backend:
serviceName: test
servicePort: 80
```

The ingress controller would define the following location blocks (in this order) within the NGINX template for the `test.com` server:

```txt
location ~* ^/foo/bar/[A-Z0-9]{3} {
location ~* "^/foo/bar/[A-Z0-9]{3}" {
...
}
location ~* ^/foo/bar/bar {
location ~* "^/foo/bar/bar" {
...
}
```
Expand Down

0 comments on commit 222270a

Please sign in to comment.