ReplacePath

Updating the Path Before Forwarding the Request

Replace the path of the request url.

Configuration Examples

Docker

  1. # Replace the path by /foo
  2. labels:
  3. - "traefik.http.middlewares.test-replacepath.replacepath.path=/foo"

Kubernetes

  1. # Replace the path by /foo
  2. apiVersion: traefik.containo.us/v1alpha1
  3. kind: Middleware
  4. metadata:
  5. name: test-replacepath
  6. spec:
  7. replacePath:
  8. path: /foo

Consul Catalog

  1. # Replace the path by /foo
  2. - "traefik.http.middlewares.test-replacepath.replacepath.path=/foo"

Marathon

  1. "labels": {
  2. "traefik.http.middlewares.test-replacepath.replacepath.path": "/foo"
  3. }

Rancher

  1. # Replace the path by /foo
  2. labels:
  3. - "traefik.http.middlewares.test-replacepath.replacepath.path=/foo"

File (TOML)

  1. # Replace the path by /foo
  2. [http.middlewares]
  3. [http.middlewares.test-replacepath.replacePath]
  4. path = "/foo"

File (YAML)

  1. # Replace the path by /foo
  2. http:
  3. middlewares:
  4. test-replacepath:
  5. replacePath:
  6. path: "/foo"

Configuration Options

General

The ReplacePath middleware will:

  • replace the actual path by the specified one.
  • store the original path in a X-Replaced-Path header.

path

The path option defines the path to use as replacement in the request url.