Routers
Connecting Requests to Services Routers analyze incoming requests and determine which service should handle them based on configurable rules. They are part of the dynamic configuration.HTTP Routers
Basic Router Configuration
- YAML
- TOML
string
required
Matching rule that determines if this router handles the request
string
required
Name of the service to forward matching requests to
array
List of EntryPoints to listen on. If not specified, listens on all default EntryPoints
Routing Rules
Rules determine which requests match a router using matchers and logical operators.Available Matchers
matcher
Match requests to specific domain
matcher
Match requests using regular expression
matcher
Match exact path
matcher
Match path prefix
matcher
Match path using regular expression
matcher
Match HTTP method
matcher
Match requests with specific header
matcher
Match header using regular expression
matcher
Match query parameter
matcher
Match client IP address or CIDR range
Combining Rules
Use logical operators to create complex rules:Rule Examples
- Domain Routing
- Path Routing
- Header Routing
Priority
Routers are evaluated by priority. Higher priority routers are checked first.- YAML
- TOML
By default, priority equals the length of the rule. Longer rules have higher priority.
Middlewares
Attach middlewares to process requests before forwarding to services:- YAML
- TOML
Middlewares are applied in the order they appear in the list.
TLS Configuration
Basic TLS
Enable TLS termination:- YAML
- TOML
Automatic Certificate Resolution
- YAML
- TOML
TCP Routers
TCP routers handle non-HTTP TCP connections:- YAML
- TOML
TCP Router Rules
matcher
Match Server Name Indication
matcher
Match all non-TLS connections
matcher
Match client IP
TLS Passthrough
Forward TLS connections without decryption:- YAML
- TOML
Complete Example
- YAML