Fix basics doc

Signed-off-by: Emile Vauge <emile@vauge.com>
This commit is contained in:
Emile Vauge 2016-07-19 10:25:47 +02:00
parent d1b5cf99d0
commit 2d759df47a
No known key found for this signature in database
GPG key ID: D808B4C167352E59

View file

@ -80,24 +80,24 @@ Here is an example of frontends definition:
[frontends.frontend1] [frontends.frontend1]
backend = "backend2" backend = "backend2"
[frontends.frontend1.routes.test_1] [frontends.frontend1.routes.test_1]
rule = "Host: test.localhost, test2.localhost" rule = "Host:test.localhost,test2.localhost"
[frontends.frontend2] [frontends.frontend2]
backend = "backend1" backend = "backend1"
passHostHeader = true passHostHeader = true
priority = 10 priority = 10
entrypoints = ["https"] # overrides defaultEntryPoints entrypoints = ["https"] # overrides defaultEntryPoints
[frontends.frontend2.routes.test_1] [frontends.frontend2.routes.test_1]
rule = "Host: localhost, {subdomain:[a-z]+}.localhost" rule = "Host:localhost,{subdomain:[a-z]+}.localhost"
[frontends.frontend3] [frontends.frontend3]
backend = "backend2" backend = "backend2"
[frontends.frontend3.routes.test_1] [frontends.frontend3.routes.test_1]
rule = "Host: test3.localhost;Path:/test" rule = "Host:test3.localhost;Path:/test"
``` ```
- Three frontends are defined: `frontend1`, `frontend2` and `frontend3` - Three frontends are defined: `frontend1`, `frontend2` and `frontend3`
- `frontend1` will forward the traffic to the `backend2` if the rule `Host: test.localhost, test2.localhost` is matched - `frontend1` will forward the traffic to the `backend2` if the rule `Host:test.localhost,test2.localhost` is matched
- `frontend2` will forward the traffic to the `backend1` if the rule `Host: localhost, {subdomain:[a-z]+}.localhost` is matched (forwarding client `Host` header to the backend) - `frontend2` will forward the traffic to the `backend1` if the rule `Host:localhost,{subdomain:[a-z]+}.localhost` is matched (forwarding client `Host` header to the backend)
- `frontend3` will forward the traffic to the `backend2` if the rules `Host: test3.localhost` **and** `Path:/test` are matched - `frontend3` will forward the traffic to the `backend2` if the rules `Host:test3.localhost` **AND** `Path:/test` are matched
### Combining multiple rules ### Combining multiple rules
@ -108,19 +108,19 @@ In TOML file, you can use multiple routes:
[frontends.frontend3] [frontends.frontend3]
backend = "backend2" backend = "backend2"
[frontends.frontend3.routes.test_1] [frontends.frontend3.routes.test_1]
rule = "Host: test3.localhost" rule = "Host:test3.localhost"
[frontends.frontend3.routes.test_2] [frontends.frontend3.routes.test_2]
rule = "Host: Path:/test" rule = "Host:Path:/test"
``` ```
Here `frontend3` will forward the traffic to the `backend2` if the rules `Host: test3.localhost` **and** `Path:/test` are matched. Here `frontend3` will forward the traffic to the `backend2` if the rules `Host:test3.localhost` **AND** `Path:/test` are matched.
You can also use the notation using a `;` separator: You can also use the notation using a `;` separator, same result:
```toml ```toml
[frontends.frontend3] [frontends.frontend3]
backend = "backend2" backend = "backend2"
[frontends.frontend3.routes.test_1] [frontends.frontend3.routes.test_1]
rule = "Host: test3.localhost;Path:/test" rule = "Host:test3.localhost;Path:/test"
``` ```
Finally, you can create a rule to bind multiple domains or Path to a frontend, using the `,` separator: Finally, you can create a rule to bind multiple domains or Path to a frontend, using the `,` separator:
@ -128,7 +128,7 @@ Finally, you can create a rule to bind multiple domains or Path to a frontend, u
```toml ```toml
[frontends.frontend2] [frontends.frontend2]
[frontends.frontend2.routes.test_1] [frontends.frontend2.routes.test_1]
rule = "Host: test1.localhost,Host: test2.localhost" rule = "Host:test1.localhost,test2.localhost"
[frontends.frontend3] [frontends.frontend3]
backend = "backend2" backend = "backend2"
[frontends.frontend3.routes.test_1] [frontends.frontend3.routes.test_1]
@ -137,7 +137,7 @@ Finally, you can create a rule to bind multiple domains or Path to a frontend, u
### Priorities ### Priorities
By default, routes will be sorted using rules length (to avoid path overlap): By default, routes will be sorted (in descending order) using rules length (to avoid path overlap):
`PathPrefix:/12345` will be matched before `PathPrefix:/1234` that will be matched before `PathPrefix:/1`. `PathPrefix:/12345` will be matched before `PathPrefix:/1234` that will be matched before `PathPrefix:/1`.
You can customize priority by frontend: You can customize priority by frontend:
@ -158,6 +158,8 @@ You can customize priority by frontend:
rule = "PathPrefix:/toto" rule = "PathPrefix:/toto"
``` ```
Here, `frontend1` will be matched before `frontend2` (`10 > 5`).
## Backends ## Backends
A backend is responsible to load-balance the traffic coming from one or more frontends to a set of http servers. A backend is responsible to load-balance the traffic coming from one or more frontends to a set of http servers.