2019-03-14 08:30:04 +00:00
# Routers
Connecting Requests to Services
{: .subtitle }
![routers ](../../assets/img/routers.png )
A router is in charge of connecting incoming requests to the services that can handle them.
2020-02-11 00:26:04 +00:00
In the process, routers may use pieces of [middleware ](../../middlewares/overview.md ) to update the request,
or act before forwarding the request to the service.
2019-03-14 08:30:04 +00:00
## Configuration Example
??? example "Requests /foo are Handled by service-foo -- Using the [File Provider ](../../providers/file.md )"
2019-07-01 09:30:05 +00:00
```yaml tab="YAML"
2019-09-23 12:32:04 +00:00
## Dynamic configuration
http:
routers:
my-router:
rule: "Path(`/foo`)"
service: service-foo
2019-07-01 09:30:05 +00:00
```
2019-03-14 08:30:04 +00:00
2021-06-18 22:08:08 +00:00
```toml tab="TOML"
2019-09-23 12:32:04 +00:00
## Dynamic configuration
2021-06-18 22:08:08 +00:00
[http.routers]
[http.routers.my-router]
rule = "Path(`/foo`)"
service = "service-foo"
2019-06-21 08:54:04 +00:00
```
2021-06-18 22:08:08 +00:00
??? example "Forwarding all (non-tls) requests on port 3306 to a database service"
**Dynamic Configuration**
2019-09-23 12:32:04 +00:00
```yaml tab="File (YAML)"
## Dynamic configuration
2019-07-01 09:30:05 +00:00
tcp:
routers:
to-database:
entryPoints:
2019-09-23 15:00:06 +00:00
- "mysql"
2019-07-01 09:30:05 +00:00
# Catch every request (only available rule for non-tls routers. See below.)
rule: "HostSNI(`*`)"
service: database
2019-03-14 08:30:04 +00:00
```
2021-06-18 22:08:08 +00:00
2019-09-23 12:32:04 +00:00
```toml tab="File (TOML)"
2021-06-18 22:08:08 +00:00
## Dynamic configuration
[tcp]
[tcp.routers]
[tcp.routers.to-database]
entryPoints = ["mysql"]
# Catch every request (only available rule for non-tls routers. See below.)
rule = "HostSNI(`*`)"
service = "database"
2019-09-23 12:32:04 +00:00
```
2021-06-18 22:08:08 +00:00
**Static Configuration**
2019-09-23 12:32:04 +00:00
```yaml tab="File (YAML)"
## Static configuration
entryPoints:
web:
address: ":80"
mysql:
2021-06-18 22:08:08 +00:00
address: ":3306"
```
```toml tab="File (TOML)"
## Static configuration
[entryPoints]
[entryPoints.web]
address = ":80"
[entryPoints.mysql]
address = ":3306"
2019-09-23 12:32:04 +00:00
```
2021-06-18 22:08:08 +00:00
2019-09-23 12:32:04 +00:00
```bash tab="CLI"
## Static configuration
2019-11-19 09:18:05 +00:00
--entryPoints.web.address=:80
--entryPoints.mysql.address=:3306
2019-09-23 12:32:04 +00:00
```
2019-03-14 08:30:04 +00:00
## Configuring HTTP Routers
2019-10-28 10:04:05 +00:00
!!! warning "The character `@` is not authorized in the router name"
2019-03-14 08:30:04 +00:00
### EntryPoints
2019-06-21 08:54:04 +00:00
If not specified, HTTP routers will accept requests from all defined entry points.
If you want to limit the router scope to a set of entry points, set the `entryPoints` option.
2019-03-14 08:30:04 +00:00
??? example "Listens to Every EntryPoint"
2021-06-18 22:08:08 +00:00
2019-09-23 12:32:04 +00:00
**Dynamic Configuration**
2021-06-18 22:08:08 +00:00
2019-09-23 12:32:04 +00:00
```yaml tab="File (YAML)"
## Dynamic configuration
2019-07-01 09:30:05 +00:00
http:
routers:
Router-1:
# By default, routers listen to every entry points
2020-03-13 21:50:05 +00:00
rule: "Host(`example.com`)"
2019-07-01 09:30:05 +00:00
service: "service-1"
2019-03-14 08:30:04 +00:00
```
2021-06-18 22:08:08 +00:00
2019-09-23 12:32:04 +00:00
```toml tab="File (TOML)"
2021-06-18 22:08:08 +00:00
## Dynamic configuration
[http.routers]
[http.routers.Router-1]
# By default, routers listen to every entry points
rule = "Host(`example.com`)"
service = "service-1"
2019-09-23 12:32:04 +00:00
```
2021-06-18 22:08:08 +00:00
**Static Configuration**
2019-09-23 12:32:04 +00:00
```yaml tab="File (YAML)"
## Static configuration
entryPoints:
web:
address: ":80"
websecure:
address: ":443"
other:
address: ":9090"
```
2021-06-18 22:08:08 +00:00
```toml tab="File (TOML)"
## Static configuration
[entryPoints]
[entryPoints.web]
address = ":80"
[entryPoints.websecure]
address = ":443"
[entryPoints.other]
address = ":9090"
```
2019-09-23 12:32:04 +00:00
```bash tab="CLI"
## Static configuration
2019-11-19 09:18:05 +00:00
--entrypoints.web.address=:80
--entrypoints.websecure.address=:443
--entrypoints.other.address=:9090
2019-09-23 12:32:04 +00:00
```
??? example "Listens to Specific EntryPoints"
2021-06-18 22:08:08 +00:00
2019-09-23 12:32:04 +00:00
**Dynamic Configuration**
2021-06-18 22:08:08 +00:00
2019-09-23 12:32:04 +00:00
```yaml tab="File (YAML)"
## Dynamic configuration
2019-07-01 09:30:05 +00:00
http:
routers:
Router-1:
# won't listen to entry point web
entryPoints:
2019-09-23 15:00:06 +00:00
- "websecure"
- "other"
2020-03-13 21:50:05 +00:00
rule: "Host(`example.com`)"
2019-07-01 09:30:05 +00:00
service: "service-1"
2019-03-14 08:30:04 +00:00
```
2019-09-23 12:32:04 +00:00
```toml tab="File (TOML)"
2021-06-18 22:08:08 +00:00
## Dynamic configuration
[http.routers]
[http.routers.Router-1]
# won't listen to entry point web
entryPoints = ["websecure", "other"]
rule = "Host(`example.com`)"
service = "service-1"
2019-09-23 12:32:04 +00:00
```
2021-06-18 22:08:08 +00:00
**Static Configuration**
2019-09-23 12:32:04 +00:00
```yaml tab="File (YAML)"
## Static configuration
entryPoints:
web:
address: ":80"
websecure:
address: ":443"
other:
address: ":9090"
```
2021-06-18 22:08:08 +00:00
```toml tab="File (TOML)"
## Static configuration
[entryPoints]
[entryPoints.web]
address = ":80"
[entryPoints.websecure]
address = ":443"
[entryPoints.other]
address = ":9090"
```
2019-09-23 12:32:04 +00:00
```bash tab="CLI"
## Static configuration
2019-11-19 09:18:05 +00:00
--entrypoints.web.address=:80
--entrypoints.websecure.address=:443
--entrypoints.other.address=:9090
2019-09-23 12:32:04 +00:00
```
2019-03-14 08:30:04 +00:00
### Rule
2019-10-25 15:16:05 +00:00
Rules are a set of matchers configured with values, that determine if a particular request matches specific criteria.
2019-05-17 11:32:05 +00:00
If the rule is verified, the router becomes active, calls middlewares, and then forwards the request to the service.
2019-03-14 08:30:04 +00:00
2019-10-25 15:16:05 +00:00
??? tip "Backticks or Quotes?"
To set the value of a rule, use [backticks ](https://en.wiktionary.org/wiki/backtick ) ``` ` ` `` or escaped double-quotes `\"` .
2021-06-18 22:08:08 +00:00
2022-03-17 17:02:08 +00:00
Single quotes `'` are not accepted since the values are [Golang's String Literals ](https://golang.org/ref/spec#String_literals ).
2019-10-25 15:16:05 +00:00
2020-03-13 21:50:05 +00:00
!!! example "Host is example.com"
2019-03-14 08:30:04 +00:00
```toml
2020-03-13 21:50:05 +00:00
rule = "Host(`example.com`)"
2019-03-14 08:30:04 +00:00
```
2020-03-13 21:50:05 +00:00
!!! example "Host is example.com OR Host is example.org AND path is /traefik"
2019-03-14 08:30:04 +00:00
```toml
2020-03-13 21:50:05 +00:00
rule = "Host(`example.com`) || (Host(`example.org`) & & Path(`/traefik`))"
2019-03-14 08:30:04 +00:00
```
2019-06-21 08:54:04 +00:00
2019-03-14 08:30:04 +00:00
The table below lists all the available matchers:
2020-07-13 15:58:03 +00:00
| Rule | Description |
|------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------|
| ```Headers(`key`, `value` )``` | Check if there is a key `key` defined in the headers, with the value `value` |
| ```HeadersRegexp(`key`, `regexp` )``` | Check if there is a key `key` defined in the headers, with a value that matches the regular expression `regexp` |
| ```Host(`example.com`, ...)``` | Check if the request domain (host header value) targets one of the given `domains` . |
2022-01-10 13:32:04 +00:00
| ```HostHeader(`example.com`, ...)``` | Same as `Host` , only exists for historical reasons. |
| ```HostRegexp(`example.com`, `{subdomain:[a-z]+}.example.com` , ...)``` | Match the request domain. See "Regexp Syntax" below. |
2021-03-22 20:16:04 +00:00
| ```Method(`GET`, ...)``` | Check if the request method is one of the given `methods` (`GET`, `POST` , `PUT` , `DELETE` , `PATCH` , `HEAD` ) |
2022-01-10 13:32:04 +00:00
| ```Path(`/path`, `/articles/{cat:[a-z]+}/{id:[0-9]+}` , ...)``` | Match exact request path. See "Regexp Syntax" below. |
| ```PathPrefix(`/products/`, `/articles/{cat:[a-z]+}/{id:[0-9]+}` )``` | Match request prefix path. See "Regexp Syntax" below. |
2020-07-13 15:58:03 +00:00
| ```Query(`foo=bar`, `bar=baz` )``` | Match Query String parameters. It accepts a sequence of key=value pairs. |
2021-06-07 16:14:09 +00:00
| ```ClientIP(`10.0.0.0/16`, `::1` )``` | Match if the request client IP is one of the given IP/CIDR. It accepts IPv4, IPv6 and CIDR formats. |
2019-03-14 08:30:04 +00:00
2021-03-22 20:16:04 +00:00
!!! important "Non-ASCII Domain Names"
Non-ASCII characters are not supported in `Host` and `HostRegexp` expressions, and by doing so the associated router will be invalid.
For the `Host` expression, domain names containing non-ASCII characters must be provided as punycode encoded values ([rfc 3492](https://tools.ietf.org/html/rfc3492)).
As well, when using the `HostRegexp` expressions, in order to match domain names containing non-ASCII characters, the regular expression should match a punycode encoded domain name.
2019-03-14 08:30:04 +00:00
!!! important "Regexp Syntax"
2022-01-10 13:32:04 +00:00
`HostRegexp` , `PathPrefix` , and `Path` accept an expression with zero or more groups enclosed by curly braces, which are called named regexps.
Named regexps, of the form `{name:regexp}` , are the only expressions considered for regexp matching.
The regexp name (`name` in the above example) is an arbitrary value, that exists only for historical reasons.
Any `regexp` supported by [Go's regexp package ](https://golang.org/pkg/regexp/ ) may be used.
2019-03-14 08:30:04 +00:00
2019-09-23 12:32:04 +00:00
!!! info "Combining Matchers Using Operators and Parenthesis"
2019-03-14 08:30:04 +00:00
2022-03-17 17:02:08 +00:00
The usual AND (`& & `) and OR (`||`) logical operators can be used, with the expected precedence rules,
as well as parentheses.
2019-03-14 08:30:04 +00:00
2022-03-17 17:02:08 +00:00
!!! info "Inverting a matcher"
2021-05-31 16:58:05 +00:00
2022-03-17 17:02:08 +00:00
One can invert a matcher by using the `!` operator.
2021-05-31 16:58:05 +00:00
2019-03-14 08:30:04 +00:00
!!! important "Rule, Middleware, and Services"
The rule is evaluated "before" any middleware has the opportunity to work, and "before" the request is forwarded to the service.
2019-09-23 12:32:04 +00:00
!!! info "Path Vs PathPrefix"
2019-03-14 08:30:04 +00:00
Use `Path` if your service listens on the exact path only. For instance, `Path: /products` would match `/products` but not `/products/shoes` .
Use a `*Prefix*` matcher if your service listens on a particular base path but also serves requests on sub-paths.
For instance, `PathPrefix: /products` would match `/products` but also `/products/shoes` and `/products/shirts` .
Since the path is forwarded as-is, your service is expected to listen on `/products` .
2021-06-07 16:14:09 +00:00
!!! info "ClientIP matcher"
The `ClientIP` matcher will only match the request client IP and does not use the `X-Forwarded-For` header for matching.
2019-09-26 13:16:05 +00:00
### Priority
To avoid path overlap, routes are sorted, by default, in descending order using rules length. The priority is directly equal to the length of the rule, and so the longest length has the highest priority.
A value of `0` for the priority is ignored: `priority = 0` means that the default rules length sorting is used.
??? info "How default priorities are computed"
```yaml tab="File (YAML)"
## Dynamic configuration
http:
routers:
Router-1:
2022-03-04 09:50:07 +00:00
rule: "HostRegexp(`{subdomain:[a-z]+}.traefik.com`)"
2019-09-26 13:16:05 +00:00
# ...
Router-2:
rule: "Host(`foobar.traefik.com`)"
# ...
```
```toml tab="File (TOML)"
## Dynamic configuration
[http.routers]
[http.routers.Router-1]
2022-03-04 09:50:07 +00:00
rule = "HostRegexp(`{subdomain:[a-z]+}.traefik.com`)"
2021-06-18 22:08:08 +00:00
# ...
2019-09-26 13:16:05 +00:00
[http.routers.Router-2]
rule = "Host(`foobar.traefik.com`)"
2021-06-18 22:08:08 +00:00
# ...
2019-09-26 13:16:05 +00:00
```
2021-06-18 22:08:08 +00:00
In this case, all requests with host `foobar.traefik.com` will be routed through `Router-1` instead of `Router-2` .
2022-03-04 09:50:07 +00:00
| Name | Rule | Priority |
|----------|----------------------------------------------------|----------|
2022-03-04 10:24:07 +00:00
| Router-1 | ```HostRegexp(`{subdomain:[a-z]+}.traefik.com`)``` | 44 |
2022-03-04 09:50:07 +00:00
| Router-2 | ```Host(`foobar.traefik.com`)``` | 26 |
2021-06-18 22:08:08 +00:00
The previous table shows that `Router-1` has a higher priority than `Router-2` .
To solve this issue, the priority must be set.
??? example "Set priorities -- using the [File Provider ](../../providers/file.md )"
2019-09-26 13:16:05 +00:00
```yaml tab="File (YAML)"
## Dynamic configuration
http:
routers:
Router-1:
2022-03-04 09:50:07 +00:00
rule: "HostRegexp(`{subdomain:[a-z]+}.traefik.com`)"
2019-09-26 13:16:05 +00:00
entryPoints:
- "web"
service: service-1
priority: 1
Router-2:
rule: "Host(`foobar.traefik.com`)"
entryPoints:
- "web"
priority: 2
service: service-2
```
2021-06-18 22:08:08 +00:00
```toml tab="File (TOML)"
## Dynamic configuration
[http.routers]
[http.routers.Router-1]
2022-03-04 09:50:07 +00:00
rule = "HostRegexp(`{subdomain:[a-z]+}.traefik.com`)"
2021-06-18 22:08:08 +00:00
entryPoints = ["web"]
service = "service-1"
priority = 1
[http.routers.Router-2]
rule = "Host(`foobar.traefik.com`)"
entryPoints = ["web"]
priority = 2
service = "service-2"
```
2019-09-26 13:16:05 +00:00
In this configuration, the priority is configured to allow `Router-2` to handle requests with the `foobar.traefik.com` host.
2019-03-14 08:30:04 +00:00
### Middlewares
You can attach a list of [middlewares ](../../middlewares/overview.md ) to each HTTP router.
The middlewares will take effect only if the rule matches, and before forwarding the request to the service.
2019-10-28 10:04:05 +00:00
!!! warning "The character `@` is not authorized in the middleware name."
2019-09-23 12:32:04 +00:00
!!! tip "Middlewares order"
2021-06-18 22:08:08 +00:00
2019-09-23 12:32:04 +00:00
Middlewares are applied in the same order as their declaration in **router** .
??? example "With a [middleware ](../../middlewares/overview.md ) -- using the [File Provider ](../../providers/file.md )"
```yaml tab="YAML"
## Dynamic configuration
http:
routers:
my-router:
rule: "Path(`/foo`)"
# declared elsewhere
middlewares:
- authentication
service: service-foo
```
2021-06-18 22:08:08 +00:00
```toml tab="TOML"
## Dynamic configuration
[http.routers]
[http.routers.my-router]
rule = "Path(`/foo`)"
# declared elsewhere
middlewares = ["authentication"]
service = "service-foo"
```
2019-03-14 08:30:04 +00:00
### Service
2019-09-26 10:48:05 +00:00
Each request must eventually be handled by a [service ](../services/index.md ),
which is why each router definition should include a service target,
which is basically where the request will be passed along to.
In general, a service assigned to a router should have been defined,
but there are exceptions for label-based providers.
See the specific [docker ](../providers/docker.md#service-definition ), [rancher ](../providers/rancher.md#service-definition ),
or [marathon ](../providers/marathon.md#service-definition ) documentation.
2019-03-14 08:30:04 +00:00
2020-03-17 23:32:04 +00:00
!!! warning "The character `@` is not authorized in the service name."
2019-10-28 10:04:05 +00:00
2019-09-23 12:32:04 +00:00
!!! important "HTTP routers can only target HTTP services (not TCP services)."
2019-03-14 08:30:04 +00:00
### TLS
2019-06-17 16:14:08 +00:00
#### General
When a TLS section is specified, it instructs Traefik that the current router is dedicated to HTTPS requests only (and that the router should ignore HTTP (non TLS) requests).
2019-03-14 08:30:04 +00:00
Traefik will terminate the SSL connections (meaning that it will send decrypted data to the services).
??? example "Configuring the router to accept HTTPS requests only"
2019-09-23 12:32:04 +00:00
```yaml tab="File (YAML)"
## Dynamic configuration
2019-07-01 09:30:05 +00:00
http:
routers:
Router-1:
rule: "Host(`foo-domain`) & & Path(`/foo-path/`)"
service: service-id
# will terminate the TLS request
tls: {}
2019-03-14 08:30:04 +00:00
```
2021-06-18 22:08:08 +00:00
```toml tab="File (TOML)"
## Dynamic configuration
[http.routers]
[http.routers.Router-1]
rule = "Host(`foo-domain`) & & Path(`/foo-path/`)"
service = "service-id"
# will terminate the TLS request
[http.routers.Router-1.tls]
```
2019-03-14 08:30:04 +00:00
!!! important "Routers for HTTP & HTTPS"
2019-09-23 12:32:04 +00:00
If you need to define the same route for both HTTP and HTTPS requests, you will need to define two different routers:
one with the tls section, one without.
2019-03-14 08:30:04 +00:00
??? example "HTTP & HTTPS routes"
2019-09-23 12:32:04 +00:00
```yaml tab="File (YAML)"
## Dynamic configuration
2019-07-01 09:30:05 +00:00
http:
routers:
my-https-router:
rule: "Host(`foo-domain`) & & Path(`/foo-path/`)"
service: service-id
# will terminate the TLS request
tls: {}
my-http-router:
rule: "Host(`foo-domain`) & & Path(`/foo-path/`)"
service: service-id
2019-03-14 08:30:04 +00:00
```
2021-06-18 22:08:08 +00:00
```toml tab="File (TOML)"
## Dynamic configuration
[http.routers]
[http.routers.my-https-router]
rule = "Host(`foo-domain`) & & Path(`/foo-path/`)"
service = "service-id"
# will terminate the TLS request
[http.routers.my-https-router.tls]
[http.routers.my-http-router]
rule = "Host(`foo-domain`) & & Path(`/foo-path/`)"
service = "service-id"
```
#### `options`
The `options` field enables fine-grained control of the TLS parameters.
It refers to a [TLS Options ](../../https/tls.md#tls-options ) and will be applied only if a `Host` rule is defined.
!!! info "Server Name Association"
Even though one might get the impression that a TLS options reference is mapped to a router, or a router rule,
2019-09-23 12:32:04 +00:00
one should realize that it is actually mapped only to the host name found in the `Host` part of the rule.
Of course, there could also be several `Host` parts in a rule, in which case the TLS options reference would be mapped to as many host names.
2019-07-03 17:22:05 +00:00
2019-09-23 12:32:04 +00:00
Another thing to keep in mind is:
the TLS option is picked from the mapping mentioned above and based on the server name provided during the TLS handshake,
and it all happens before routing actually occurs.
2019-07-03 17:22:05 +00:00
2020-07-17 13:38:04 +00:00
!!! info "Domain Fronting"
In the case of domain fronting,
if the TLS options associated with the Host Header and the SNI are different then Traefik will respond with a status code `421` .
2019-07-01 09:30:05 +00:00
??? example "Configuring the TLS options"
2019-06-17 16:14:08 +00:00
2019-09-23 12:32:04 +00:00
```yaml tab="File (YAML)"
## Dynamic configuration
2019-07-01 09:30:05 +00:00
http:
routers:
Router-1:
rule: "Host(`foo-domain`) & & Path(`/foo-path/`)"
service: service-id
# will terminate the TLS request
tls:
options: foo
2021-06-18 22:08:08 +00:00
2019-07-01 09:30:05 +00:00
tls:
options:
foo:
minVersion: VersionTLS12
cipherSuites:
2019-10-08 12:38:04 +00:00
- TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
2020-02-26 14:30:06 +00:00
- TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256
- TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256
2019-10-08 12:38:04 +00:00
- TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
2019-09-23 15:00:06 +00:00
- TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
2019-06-17 16:14:08 +00:00
```
2019-09-23 12:32:04 +00:00
```toml tab="File (TOML)"
## Dynamic configuration
2019-07-03 17:22:05 +00:00
[http.routers]
2021-06-18 22:08:08 +00:00
[http.routers.Router-1]
rule = "Host(`foo-domain`) & & Path(`/foo-path/`)"
service = "service-id"
# will terminate the TLS request
[http.routers.Router-1.tls]
2019-07-19 09:52:04 +00:00
options = "foo"
2019-07-03 17:22:05 +00:00
2021-06-18 22:08:08 +00:00
[tls.options]
[tls.options.foo]
minVersion = "VersionTLS12"
cipherSuites = [
"TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384",
"TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256",
"TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256",
"TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
]
2019-07-03 17:22:05 +00:00
```
2021-06-18 22:08:08 +00:00
!!! important "Conflicting TLS Options"
Since a TLS options reference is mapped to a host name,
if a configuration introduces a situation where the same host name (from a `Host` rule) gets matched with two TLS options references,
a conflict occurs, such as in the example below:
2019-09-23 12:32:04 +00:00
```yaml tab="File (YAML)"
## Dynamic configuration
2019-07-03 17:22:05 +00:00
http:
routers:
routerfoo:
rule: "Host(`snitest.com`) & & Path(`/foo`)"
tls:
options: foo
routerbar:
rule: "Host(`snitest.com`) & & Path(`/bar`)"
tls:
options: bar
```
2021-06-18 22:08:08 +00:00
```toml tab="File (TOML)"
## Dynamic configuration
[http.routers]
[http.routers.routerfoo]
rule = "Host(`snitest.com`) & & Path(`/foo`)"
[http.routers.routerfoo.tls]
options = "foo"
[http.routers]
[http.routers.routerbar]
rule = "Host(`snitest.com`) & & Path(`/bar`)"
[http.routers.routerbar.tls]
options = "bar"
```
2019-07-03 17:22:05 +00:00
If that happens, both mappings are discarded, and the host name (`snitest.com` in this case) for these routers gets associated with the default TLS options instead.
2019-07-19 09:52:04 +00:00
#### `certResolver`
If `certResolver` is defined, Traefik will try to generate certificates based on routers `Host` & `HostSNI` rules.
2019-09-23 12:32:04 +00:00
```yaml tab="File (YAML)"
## Dynamic configuration
2019-07-19 09:52:04 +00:00
http:
routers:
routerfoo:
rule: "Host(`snitest.com`) & & Path(`/foo`)"
tls:
certResolver: foo
```
2021-06-18 22:08:08 +00:00
```toml tab="File (TOML)"
## Dynamic configuration
[http.routers]
[http.routers.routerfoo]
rule = "Host(`snitest.com`) & & Path(`/foo`)"
[http.routers.routerfoo.tls]
certResolver = "foo"
```
2019-09-23 12:32:04 +00:00
!!! info "Multiple Hosts in a Rule"
2020-03-13 21:50:05 +00:00
The rule ```Host(`test1.example.com`,`test2.example.com`)``` will request a certificate with the main domain `test1.example.com` and SAN `test2.example.com` .
2019-07-19 09:52:04 +00:00
#### `domains`
You can set SANs (alternative domains) for each main domain.
Every domain must have A/AAAA records pointing to Traefik.
Each domain & SAN will lead to a certificate request.
2019-09-23 12:32:04 +00:00
```yaml tab="File (YAML)"
## Dynamic configuration
2019-07-19 09:52:04 +00:00
http:
routers:
routerbar:
rule: "Host(`snitest.com`) & & Path(`/bar`)"
tls:
certResolver: "bar"
2019-08-05 15:22:04 +00:00
domains:
2019-09-23 15:00:06 +00:00
- main: "snitest.com"
2019-10-07 07:48:04 +00:00
sans:
- "*.snitest.com"
2019-07-19 09:52:04 +00:00
```
2021-06-18 22:08:08 +00:00
```toml tab="File (TOML)"
## Dynamic configuration
[http.routers]
[http.routers.routerbar]
rule = "Host(`snitest.com`) & & Path(`/bar`)"
[http.routers.routerbar.tls]
certResolver = "bar"
[[http.routers.routerbar.tls.domains]]
main = "snitest.com"
sans = ["*.snitest.com"]
```
2019-07-19 09:52:04 +00:00
[ACME v2 ](https://community.letsencrypt.org/t/acme-v2-and-wildcard-certificate-support-is-live/55579 ) supports wildcard certificates.
2019-07-22 07:58:04 +00:00
As described in [Let's Encrypt's post ](https://community.letsencrypt.org/t/staging-endpoint-for-acme-v2/49605 ) wildcard certificates can only be generated through a [`DNS-01` challenge ](../../https/acme.md#dnschallenge ).
2019-07-19 09:52:04 +00:00
Most likely the root domain should receive a certificate too, so it needs to be specified as SAN and 2 `DNS-01` challenges are executed.
In this case the generated DNS TXT record for both domains is the same.
Even though this behavior is [DNS RFC ](https://community.letsencrypt.org/t/wildcard-issuance-two-txt-records-for-the-same-name/54528/2 ) compliant,
it can lead to problems as all DNS providers keep DNS records cached for a given time (TTL) and this TTL can be greater than the challenge timeout making the `DNS-01` challenge fail.
2019-09-23 12:32:04 +00:00
The Traefik ACME client library [lego ](https://github.com/go-acme/lego ) supports some but not all DNS providers to work around this issue.
The [supported `provider` table ](../../https/acme.md#providers ) indicates if they allow generating certificates for a wildcard domain and its root domain.
2019-07-19 09:52:04 +00:00
2019-09-23 12:32:04 +00:00
!!! important "Wildcard certificates can only be verified through a [`DNS-01` challenge ](../../https/acme.md#dnschallenge )."
2019-07-19 09:52:04 +00:00
2019-09-23 12:32:04 +00:00
!!! warning "Double Wildcard Certificates"
2019-07-19 09:52:04 +00:00
It is not possible to request a double wildcard certificate for a domain (for example `*.*.local.com` ).
2019-03-14 08:30:04 +00:00
## Configuring TCP Routers
2019-10-28 10:04:05 +00:00
!!! warning "The character `@` is not authorized in the router name"
2019-03-14 08:30:04 +00:00
### General
2019-06-19 17:00:06 +00:00
If both HTTP routers and TCP routers listen to the same entry points, the TCP routers will apply *before* the HTTP routers.
2019-03-14 08:30:04 +00:00
If no matching route is found for the TCP routers, then the HTTP routers will take over.
### EntryPoints
2019-06-19 17:00:06 +00:00
If not specified, TCP routers will accept requests from all defined entry points.
If you want to limit the router scope to a set of entry points, set the entry points option.
2019-03-14 08:30:04 +00:00
2019-06-21 08:54:04 +00:00
??? example "Listens to Every Entry Point"
2021-06-18 22:08:08 +00:00
2019-09-23 12:32:04 +00:00
**Dynamic Configuration**
```yaml tab="File (YAML)"
## Dynamic configuration
2021-06-18 22:08:08 +00:00
2019-07-01 09:30:05 +00:00
tcp:
routers:
Router-1:
2019-03-14 08:30:04 +00:00
# By default, routers listen to every entrypoints
2020-03-13 21:50:05 +00:00
rule: "HostSNI(`example.com`)"
2019-07-01 09:30:05 +00:00
service: "service-1"
# will route TLS requests (and ignore non tls requests)
tls: {}
2019-03-14 08:30:04 +00:00
```
2019-09-23 12:32:04 +00:00
```toml tab="File (TOML)"
2021-06-18 22:08:08 +00:00
## Dynamic configuration
[tcp.routers]
[tcp.routers.Router-1]
# By default, routers listen to every entrypoints
rule = "HostSNI(`example.com`)"
service = "service-1"
# will route TLS requests (and ignore non tls requests)
[tcp.routers.Router-1.tls]
2019-09-23 12:32:04 +00:00
```
2021-06-18 22:08:08 +00:00
**Static Configuration**
2019-09-23 12:32:04 +00:00
```yaml tab="File (YAML)"
## Static configuration
2021-06-18 22:08:08 +00:00
2019-09-23 12:32:04 +00:00
entryPoints:
web:
address: ":80"
websecure:
address: ":443"
other:
address: ":9090"
```
2021-06-18 22:08:08 +00:00
```toml tab="File (TOML)"
## Static configuration
[entryPoints]
[entryPoints.web]
address = ":80"
[entryPoints.websecure]
address = ":443"
[entryPoints.other]
address = ":9090"
```
2019-09-23 12:32:04 +00:00
```bash tab="CLI"
## Static configuration
2019-11-19 09:18:05 +00:00
--entrypoints.web.address=:80
--entrypoints.websecure.address=:443
--entrypoints.other.address=:9090
2019-09-23 12:32:04 +00:00
```
??? example "Listens to Specific Entry Points"
2021-06-18 22:08:08 +00:00
2019-09-23 12:32:04 +00:00
**Dynamic Configuration**
2021-06-18 22:08:08 +00:00
2019-09-23 12:32:04 +00:00
```yaml tab="File (YAML)"
## Dynamic configuration
2019-07-01 09:30:05 +00:00
tcp:
routers:
Router-1:
# won't listen to entry point web
entryPoints:
2019-09-23 15:00:06 +00:00
- "websecure"
- "other"
2020-03-13 21:50:05 +00:00
rule: "HostSNI(`example.com`)"
2019-07-01 09:30:05 +00:00
service: "service-1"
# will route TLS requests (and ignore non tls requests)
tls: {}
2019-03-14 08:30:04 +00:00
```
2019-09-23 12:32:04 +00:00
```toml tab="File (TOML)"
2021-06-18 22:08:08 +00:00
## Dynamic configuration
[tcp.routers]
[tcp.routers.Router-1]
# won't listen to entry point web
entryPoints = ["websecure", "other"]
rule = "HostSNI(`example.com`)"
service = "service-1"
# will route TLS requests (and ignore non tls requests)
[tcp.routers.Router-1.tls]
2019-09-23 12:32:04 +00:00
```
2021-06-18 22:08:08 +00:00
**Static Configuration**
2019-09-23 12:32:04 +00:00
```yaml tab="File (YAML)"
## Static configuration
2021-06-18 22:08:08 +00:00
2019-09-23 12:32:04 +00:00
entryPoints:
web:
address: ":80"
websecure:
address: ":443"
other:
address: ":9090"
```
2021-06-18 22:08:08 +00:00
```toml tab="File (TOML)"
## Static configuration
[entryPoints]
[entryPoints.web]
address = ":80"
[entryPoints.websecure]
address = ":443"
[entryPoints.other]
address = ":9090"
```
2019-09-23 12:32:04 +00:00
```bash tab="CLI"
## Static configuration
2019-11-19 09:18:05 +00:00
--entrypoints.web.address=:80
--entrypoints.websecure.address=:443
--entrypoints.other.address=:9090
2019-09-23 12:32:04 +00:00
```
2019-03-14 08:30:04 +00:00
### Rule
2022-03-17 17:02:08 +00:00
Rules are a set of matchers configured with values, that determine if a particular request matches specific criteria.
If the rule is verified, the router becomes active, calls middlewares, and then forwards the request to the service.
??? tip "Backticks or Quotes?"
To set the value of a rule, use [backticks ](https://en.wiktionary.org/wiki/backtick ) ``` ` ` `` or escaped double-quotes `\"` .
Single quotes `'` are not accepted since the values are [Golang's String Literals ](https://golang.org/ref/spec#String_literals ).
!!! example "HostSNI is example.com"
```toml
rule = "HostSNI(`example.com`)"
```
!!! example "HostSNI is example.com OR HostSNI is example.org AND ClientIP is 0.0.0.0"
```toml
rule = "HostSNI(`example.com`) || (HostSNI(`example.org`) & & ClientIP(`0.0.0.0`))"
```
The table below lists all the available matchers:
2022-03-18 15:04:08 +00:00
| Rule | Description |
|---------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------|
| ```HostSNI(`domain-1`, ...)``` | Check if the Server Name Indication corresponds to the given `domains` . |
| ```HostSNIRegexp(`example.com`, `{subdomain:[a-z]+}.example.com` , ...)``` | Check if the Server Name Indication matches the given regular expressions. See "Regexp Syntax" below. |
| ```ClientIP(`10.0.0.0/16`, `::1` )``` | Check if the request client IP is one of the given IP/CIDR. It accepts IPv4, IPv6 and CIDR formats. |
2019-03-14 08:30:04 +00:00
2021-03-22 20:16:04 +00:00
!!! important "Non-ASCII Domain Names"
2022-03-18 15:04:08 +00:00
Non-ASCII characters are not supported in the `HostSNI` and `HostSNIRegexp` expressions, and so using them would invalidate the associated TCP router.
2021-03-22 20:16:04 +00:00
Domain names containing non-ASCII characters must be provided as punycode encoded values ([rfc 3492](https://tools.ietf.org/html/rfc3492)).
2022-03-18 15:04:08 +00:00
!!! important "Regexp Syntax"
`HostSNIRegexp` accepts an expression with zero or more groups enclosed by curly braces, which are called named regexps.
Named regexps, of the form `{name:regexp}` , are the only expressions considered for regexp matching.
The regexp name (`name` in the above example) is an arbitrary value, that exists only for historical reasons.
Any `regexp` supported by [Go's regexp package ](https://golang.org/pkg/regexp/ ) may be used.
2019-03-14 08:30:04 +00:00
!!! important "HostSNI & TLS"
It is important to note that the Server Name Indication is an extension of the TLS protocol.
Hence, only TLS routers will be able to specify a domain name with that rule.
2022-03-17 17:02:08 +00:00
However, there is one special use case for HostSNI with non-TLS routers:
when one wants a non-TLS router that matches all (non-TLS) requests,
one should use the specific `HostSNI(*)` syntax.
!!! info "Combining Matchers Using Operators and Parenthesis"
The usual AND (`& & `) and OR (`||`) logical operators can be used, with the expected precedence rules,
as well as parentheses.
!!! info "Inverting a matcher"
One can invert a matcher by using the `!` operator.
!!! important "Rule, Middleware, and Services"
The rule is evaluated "before" any middleware has the opportunity to work, and "before" the request is forwarded to the service.
### Priority
To avoid path overlap, routes are sorted, by default, in descending order using rules length.
The priority is directly equal to the length of the rule, and so the longest length has the highest priority.
A value of `0` for the priority is ignored: `priority = 0` means that the default rules length sorting is used.
??? info "How default priorities are computed"
```yaml tab="File (YAML)"
## Dynamic configuration
tcp:
routers:
Router-1:
rule: "ClientIP(`192.168.0.12`)"
# ...
Router-2:
rule: "ClientIP(`192.168.0.0/24`)"
# ...
```
```toml tab="File (TOML)"
## Dynamic configuration
[tcp.routers]
[tcp.routers.Router-1]
rule = "ClientIP(`192.168.0.12`)"
# ...
[tcp.routers.Router-2]
rule = "ClientIP(`192.168.0.0/24`)"
# ...
```
The table below shows that `Router-2` has a higher computed priority than `Router-1` .
| Name | Rule | Priority |
|----------|-------------------------------------------------------------|----------|
| Router-1 | ```ClientIP(`192.168.0.12`)``` | 24 |
| Router-2 | ```ClientIP(`192.168.0.0/24`)``` | 26 |
Which means that requests from `192.168.0.12` would go to Router-2 even though Router-1 is intended to specifically handle them.
To achieve this intention, a priority (higher than 26) should be set on Router-1.
??? example "Setting priorities -- using the [File Provider ](../../providers/file.md )"
```yaml tab="File (YAML)"
## Dynamic configuration
tcp:
routers:
Router-1:
rule: "ClientIP(`192.168.0.12`)"
entryPoints:
- "web"
service: service-1
priority: 2
Router-2:
rule: "ClientIP(`192.168.0.0/24`)"
entryPoints:
- "web"
priority: 1
service: service-2
```
```toml tab="File (TOML)"
## Dynamic configuration
[tcp.routers]
[tcp.routers.Router-1]
rule = "ClientIP(`192.168.0.12`)"
entryPoints = ["web"]
service = "service-1"
priority = 2
[tcp.routers.Router-2]
rule = "ClientIP(`192.168.0.0/24`)"
entryPoints = ["web"]
priority = 1
service = "service-2"
```
In this configuration, the priority is configured so that `Router-1` will handle requests from `192.168.0.12` .
2019-03-14 08:30:04 +00:00
2021-06-11 13:30:05 +00:00
### Middlewares
You can attach a list of [middlewares ](../../middlewares/overview.md ) to each TCP router.
The middlewares will take effect only if the rule matches, and before connecting to the service.
!!! warning "The character `@` is not allowed to be used in the middleware name."
!!! tip "Middlewares order"
Middlewares are applied in the same order as their declaration in **router** .
??? example "With a [middleware ](../../middlewares/tcp/overview.md ) -- using the [File Provider ](../../providers/file.md )"
```toml tab="TOML"
## Dynamic configuration
[tcp.routers]
[tcp.routers.my-router]
rule = "HostSNI(`*`)"
# declared elsewhere
middlewares = ["ipwhitelist"]
service = "service-foo"
```
```yaml tab="YAML"
## Dynamic configuration
tcp:
routers:
my-router:
rule: "HostSNI(`*`)"
# declared elsewhere
middlewares:
- ipwhitelist
service: service-foo
```
2019-03-14 08:30:04 +00:00
### Services
You must attach a TCP [service ](../services/index.md ) per TCP router.
Services are the target for the router.
2019-09-23 12:32:04 +00:00
!!! important "TCP routers can only target TCP services (not HTTP services)."
2019-03-14 08:30:04 +00:00
### TLS
2019-06-17 16:14:08 +00:00
#### General
2020-02-11 00:26:04 +00:00
When a TLS section is specified,
it instructs Traefik that the current router is dedicated to TLS requests only (and that the router should ignore non-TLS requests).
2019-03-14 08:30:04 +00:00
2020-03-10 16:28:04 +00:00
By default, a router with a TLS section will terminate the TLS connections, meaning that it will send decrypted data to the services.
??? example "Router for TLS requests"
2019-03-14 08:30:04 +00:00
2019-09-23 12:32:04 +00:00
```yaml tab="File (YAML)"
## Dynamic configuration
2019-07-01 09:30:05 +00:00
tcp:
routers:
Router-1:
rule: "HostSNI(`foo-domain`)"
service: service-id
# will terminate the TLS request by default
2019-09-05 08:48:04 +00:00
tls: {}
2019-03-14 08:30:04 +00:00
```
2019-09-23 12:32:04 +00:00
```toml tab="File (TOML)"
## Dynamic configuration
2019-03-14 08:30:04 +00:00
[tcp.routers]
2019-07-01 09:30:05 +00:00
[tcp.routers.Router-1]
rule = "HostSNI(`foo-domain`)"
service = "service-id"
2021-06-18 22:08:08 +00:00
# will terminate the TLS request by default
2019-07-01 09:30:05 +00:00
[tcp.routers.Router-1.tls]
```
2021-06-18 22:08:08 +00:00
#### `passthrough`
As seen above, a TLS router will terminate the TLS connection by default.
However, the `passthrough` option can be specified to set whether the requests should be forwarded "as is", keeping all data encrypted.
It defaults to `false` .
??? example "Configuring passthrough"
2019-09-23 12:32:04 +00:00
```yaml tab="File (YAML)"
## Dynamic configuration
2019-07-01 09:30:05 +00:00
tcp:
routers:
Router-1:
rule: "HostSNI(`foo-domain`)"
service: service-id
tls:
passthrough: true
2019-03-14 08:30:04 +00:00
```
2019-09-23 12:32:04 +00:00
```toml tab="File (TOML)"
## Dynamic configuration
2019-06-17 16:14:08 +00:00
[tcp.routers]
2019-07-01 09:30:05 +00:00
[tcp.routers.Router-1]
rule = "HostSNI(`foo-domain`)"
service = "service-id"
[tcp.routers.Router-1.tls]
2021-06-18 22:08:08 +00:00
passthrough = true
2019-07-01 09:30:05 +00:00
```
2021-06-18 22:08:08 +00:00
#### `options`
The `options` field enables fine-grained control of the TLS parameters.
It refers to a [TLS Options ](../../https/tls.md#tls-options ) and will be applied only if a `HostSNI` rule is defined.
!!! example "Configuring the tls options"
2019-09-23 12:32:04 +00:00
```yaml tab="File (YAML)"
## Dynamic configuration
2019-07-01 09:30:05 +00:00
tcp:
routers:
Router-1:
rule: "HostSNI(`foo-domain`)"
service: service-id
# will terminate the TLS request
tls:
options: foo
2021-06-18 22:08:08 +00:00
2019-07-01 09:30:05 +00:00
tls:
options:
foo:
minVersion: VersionTLS12
cipherSuites:
2019-10-08 12:38:04 +00:00
- TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
2020-02-26 14:30:06 +00:00
- TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256
- TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256
2019-10-08 12:38:04 +00:00
- TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
- TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
2019-06-17 16:14:08 +00:00
```
2019-07-19 09:52:04 +00:00
2021-06-18 22:08:08 +00:00
```toml tab="File (TOML)"
## Dynamic configuration
[tcp.routers]
[tcp.routers.Router-1]
rule = "HostSNI(`foo-domain`)"
service = "service-id"
# will terminate the TLS request
[tcp.routers.Router-1.tls]
options = "foo"
[tls.options]
[tls.options.foo]
minVersion = "VersionTLS12"
cipherSuites = [
"TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384",
"TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256",
"TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256",
"TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
]
```
2019-07-19 09:52:04 +00:00
#### `certResolver`
See [`certResolver` for HTTP router ](./index.md#certresolver ) for more information.
2019-09-23 12:32:04 +00:00
```yaml tab="File (YAML)"
## Dynamic configuration
2019-07-19 09:52:04 +00:00
tcp:
routers:
routerfoo:
rule: "HostSNI(`snitest.com`)"
tls:
certResolver: foo
```
2019-09-23 12:32:04 +00:00
```toml tab="File (TOML)"
## Dynamic configuration
2019-07-19 09:52:04 +00:00
[tcp.routers]
2021-06-18 22:08:08 +00:00
[tcp.routers.routerfoo]
2019-07-19 09:52:04 +00:00
rule = "HostSNI(`snitest.com`)"
2021-06-18 22:08:08 +00:00
[tcp.routers.routerfoo.tls]
certResolver = "foo"
2019-07-19 09:52:04 +00:00
```
2021-06-18 22:08:08 +00:00
#### `domains`
See [`domains` for HTTP router ](./index.md#domains ) for more information.
2019-09-23 12:32:04 +00:00
```yaml tab="File (YAML)"
## Dynamic configuration
2019-07-19 09:52:04 +00:00
tcp:
routers:
routerbar:
rule: "HostSNI(`snitest.com`)"
tls:
certResolver: "bar"
2019-08-05 15:22:04 +00:00
domains:
2019-09-23 15:00:06 +00:00
- main: "snitest.com"
2021-06-18 22:08:08 +00:00
sans:
2019-10-07 07:48:04 +00:00
- "*.snitest.com"
2019-07-19 09:52:04 +00:00
```
2020-02-11 00:26:04 +00:00
2021-06-18 22:08:08 +00:00
```toml tab="File (TOML)"
## Dynamic configuration
[tcp.routers]
[tcp.routers.routerbar]
rule = "HostSNI(`snitest.com`)"
[tcp.routers.routerbar.tls]
certResolver = "bar"
[[tcp.routers.routerbar.tls.domains]]
main = "snitest.com"
sans = ["*.snitest.com"]
```
2020-02-11 00:26:04 +00:00
## Configuring UDP Routers
!!! warning "The character `@` is not allowed in the router name"
### General
Similarly to TCP, as UDP is the transport layer, there is no concept of a request,
so there is no notion of an URL path prefix to match an incoming UDP packet with.
Furthermore, as there is no good TLS support at the moment for multiple hosts,
there is no Host SNI notion to match against either.
Therefore, there is no criterion that could be used as a rule to match incoming packets in order to route them.
So UDP "routers" at this time are pretty much only load-balancers in one form or another.
!!! important "Sessions and timeout"
Even though UDP is connectionless (and because of that),
the implementation of an UDP router in Traefik relies on what we (and a couple of other implementations) call a `session` .
It basically means that some state is kept about an ongoing communication between a client and a backend,
notably so that the proxy knows where to forward a response packet from a backend.
As expected, a `timeout` is associated to each of these sessions,
2021-01-07 16:16:03 +00:00
so that they get cleaned out if they go through a period of inactivity longer than a given duration.
Timeout can be configured using the `entryPoints.name.udp.timeout` option as described
under [entry points ](../entrypoints/#udp-options ).
2020-02-11 00:26:04 +00:00
### EntryPoints
If not specified, UDP routers will accept packets from all defined (UDP) entry points.
If one wants to limit the router scope to a set of entry points, one should set the entry points option.
??? example "Listens to Every Entry Point"
**Dynamic Configuration**
```yaml tab="File (YAML)"
## Dynamic configuration
udp:
routers:
Router-1:
# By default, routers listen to all UDP entrypoints
# i.e. "other", and "streaming".
service: "service-1"
```
```toml tab="File (TOML)"
2021-06-18 22:08:08 +00:00
## Dynamic configuration
2020-02-11 00:26:04 +00:00
2021-06-18 22:08:08 +00:00
[udp.routers]
[udp.routers.Router-1]
# By default, routers listen to all UDP entrypoints,
# i.e. "other", and "streaming".
service = "service-1"
2020-02-11 00:26:04 +00:00
```
2021-06-18 22:08:08 +00:00
**Static Configuration**
2020-02-11 00:26:04 +00:00
```yaml tab="File (YAML)"
## Static configuration
entryPoints:
# not used by UDP routers
web:
address: ":80"
# used by UDP routers
other:
address: ":9090/udp"
streaming:
address: ":9191/udp"
```
2021-06-18 22:08:08 +00:00
```toml tab="File (TOML)"
## Static configuration
[entryPoints]
# not used by UDP routers
[entryPoints.web]
address = ":80"
# used by UDP routers
[entryPoints.other]
address = ":9090/udp"
[entryPoints.streaming]
address = ":9191/udp"
```
2020-02-11 00:26:04 +00:00
```bash tab="CLI"
## Static configuration
--entrypoints.web.address=":80"
--entrypoints.other.address=":9090/udp"
--entrypoints.streaming.address=":9191/udp"
```
??? example "Listens to Specific Entry Points"
**Dynamic Configuration**
```yaml tab="File (YAML)"
## Dynamic configuration
udp:
routers:
Router-1:
# does not listen on "other" entry point
entryPoints:
- "streaming"
service: "service-1"
```
```toml tab="File (TOML)"
2021-06-18 22:08:08 +00:00
## Dynamic configuration
[udp.routers]
[udp.routers.Router-1]
# does not listen on "other" entry point
entryPoints = ["streaming"]
service = "service-1"
2020-02-11 00:26:04 +00:00
```
2021-06-18 22:08:08 +00:00
**Static Configuration**
2020-02-11 00:26:04 +00:00
```yaml tab="File (YAML)"
## Static configuration
entryPoints:
web:
address: ":80"
other:
address: ":9090/udp"
streaming:
address: ":9191/udp"
```
2021-06-18 22:08:08 +00:00
```toml tab="File (TOML)"
## Static configuration
[entryPoints]
[entryPoints.web]
address = ":80"
[entryPoints.other]
address = ":9090/udp"
[entryPoints.streaming]
address = ":9191/udp"
```
2020-02-11 00:26:04 +00:00
```bash tab="CLI"
## Static configuration
--entrypoints.web.address=":80"
--entrypoints.other.address=":9090/udp"
--entrypoints.streaming.address=":9191/udp"
```
### Services
There must be one (and only one) UDP [service ](../services/index.md ) referenced per UDP router.
Services are the target for the router.
!!! important "UDP routers can only target UDP services (and not HTTP or TCP services)."