Add Prefix

Prefixing the Path

AddPrefix

The AddPrefix middleware updates the path of a request before forwarding it.

Configuration Examples

Docker & Swarm

  1. # Prefixing with /foo
  2. labels:
  3. - "traefik.http.middlewares.add-foo.addprefix.prefix=/foo"

Kubernetes

  1. # Prefixing with /foo
  2. apiVersion: traefik.io/v1alpha1
  3. kind: Middleware
  4. metadata:
  5. name: add-foo
  6. spec:
  7. addPrefix:
  8. prefix: /foo

Consul Catalog

  1. # Prefixing with /foo
  2. - "traefik.http.middlewares.add-foo.addprefix.prefix=/foo"

File (YAML)

  1. # Prefixing with /foo
  2. http:
  3. middlewares:
  4. add-foo:
  5. addPrefix:
  6. prefix: "/foo"

File (TOML)

  1. # Prefixing with /foo
  2. [http.middlewares]
  3. [http.middlewares.add-foo.addPrefix]
  4. prefix = "/foo"

Configuration Options

prefix

prefix is the string to add before the current path in the requested URL. It should include a leading slash (/).