Add Prefix
Prefixing the Path
The AddPrefix middleware updates the path of a request before forwarding it.
Configuration Examples
Docker
# Prefixing with /foo
labels:
- "traefik.http.middlewares.add-foo.addprefix.prefix=/foo"
Kubernetes
# Prefixing with /foo
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
name: add-foo
spec:
addPrefix:
prefix: /foo
Consul Catalog
# Prefixing with /foo
- "traefik.http.middlewares.add-foo.addprefix.prefix=/foo"
Marathon
"labels": {
"traefik.http.middlewares.add-foo.addprefix.prefix": "/foo"
}
Rancher
# Prefixing with /foo
labels:
- "traefik.http.middlewares.add-foo.addprefix.prefix=/foo"
File (YAML)
# Prefixing with /foo
http:
middlewares:
add-foo:
addPrefix:
prefix: "/foo"
File (TOML)
# Prefixing with /foo
[http.middlewares]
[http.middlewares.add-foo.addPrefix]
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 (/
).