Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the sample ingress spec error #3271

Merged
merged 1 commit into from
Oct 19, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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