Skip to content

middlewares

Reusable request and response policies.

Set, add or remove request and response headers.

Type: object

HTTP Strict Transport Security, sent on HTTPS responses only.

middlewares.<name>.hsts.include_subdomains

Section titled “middlewares.<name>.hsts.include_subdomains”

Type: boolean · Default: false

Apply the policy to all subdomains too.

Type: Duration · Required

How long browsers remember the policy. 0s removes it.

Type: boolean · Default: false

Ask for inclusion in browser preload lists. This is hard to undo.

Type: object · Default: {"add":{},"remove":[],"set":{}}

Changes to the request sent to the backend.

Type: map of names to string

Append header values.

Type: list of string

Remove headers.

Type: map of names to string

Replace headers.

Type: object · Default: {"add":{},"remove":[],"set":{}}

Changes to the response sent to the client.

Type: map of names to string

Append header values.

Type: list of string

Remove headers.

Type: map of names to string

Replace headers.

Redirect to another scheme or to a URL built from a regular expression.

Type: boolean · Default: false

301/308 when true, 302/307 when false (the second code of each pair is used for methods other than GET, so the method and body are kept), as in Traefik.

Type: integer

Port for scheme redirects when it is not the scheme’s default.

Type: string

Regular expression matched against the full request URL.

Type: string

Target URL; may use $1, ${name} groups from regex.

Type: http · https

Redirect to this scheme, keeping host, path and query.

  • http: http://.
  • https: https://.

Rewrite the path with a regular expression.

Type: string · Required

Regular expression matched against the path.

Type: string · Required

Replacement path; may use $1, ${name} groups.

Remove a path prefix before forwarding.

Type: list of string · Required

Prefixes to remove; the first that matches is used.

Add a path prefix before forwarding.

Type: string · Required

Prefix to add, starting with /.

Replace the whole path before forwarding.

Type: string · Required

New path, starting with /.

HTTP Basic authentication with hashed passwords.

Type: string

Realm shown by browsers.

Type: boolean · Default: false

Remove the Authorization header before forwarding.

Type: list of string

user:hash entries.

Type: string

File with one user:hash entry per line.

Ask an external service (Authelia, Authentik, oauth2-proxy…) whether to allow a request.

Type: HttpUrl · Required

Authentication endpoint. A 2xx answer allows the request; anything else is returned to the client.

Type: list of string

Response headers of the auth service copied to the forwarded request.

Type: list of string

Request headers sent to the auth service (all when empty).

Type: Duration · Default: 5s

Time allowed for the auth service. Requests fail closed on timeout.

Type: boolean · Default: false

Trust X-Forwarded-* headers already present on the request.

Allow only these client networks.

Type: list of IpNetwork · Required

IP addresses or CIDR ranges.

Reject these client networks.

Type: list of IpNetwork · Required

IP addresses or CIDR ranges.

Token-bucket rate limiting.

Type: integer · Required

Requests allowed per period on average.

Type: integer

Largest burst; defaults to average.

Type: RateLimitKey · Default: client_ip

What to count by.

Type: Duration · Default: 1s

Period of average.

Cross-origin resource sharing.

Type: boolean · Default: false

Allow cookies and credentials. Not allowed together with *.

Type: list of string

Allowed request headers.

Type: list of string · Default: ["GET","HEAD","POST"]

Allowed methods.

Type: list of string · Required

Allowed origins (https://app.example.com) or *.

Type: list of string

Response headers exposed to scripts.

Type: Duration

How long browsers may cache the preflight answer.

Response compression.

Type: list of gzip · br · zstd · Default: ["gzip"]

Algorithms offered, in order of preference.

Type: list of string

Content types to compress; common text types when empty.

Type: ByteSize · Default: 1KiB

Smallest response compressed.

Custom error pages.

Type: string

Static HTML file to serve. Set this or service.

Type: string

Path requested from service; {status} is replaced by the code.

Type: string

Service that renders the error page. Set this or file.

Type: list of string · Required

Status codes or ranges, e.g. 404 or 500-599.

Maintenance mode.

Type: list of IpNetwork

Clients that still reach the service (e.g. your office).

Type: boolean · Default: true

Turn maintenance mode on.

Type: string

HTML page to serve.

Type: Duration

Retry-After value sent to clients.

Type: integer · Default: 503

Status code returned.