Skip to main content

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

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

Priority

Routers are evaluated by priority. Higher priority routers are checked first.
By default, priority equals the length of the rule. Longer rules have higher priority.

Middlewares

Attach middlewares to process requests before forwarding to services:
Middlewares are applied in the order they appear in the list.

TLS Configuration

Basic TLS

Enable TLS termination:

Automatic Certificate Resolution

Wildcard certificates require DNS-01 challenge. HTTP-01 challenge only works for single domains.

TCP Routers

TCP routers handle non-HTTP TCP connections:

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:

Complete Example