2019-02-26 13:50:07 +00:00
|
|
|
# Add Prefix
|
|
|
|
|
|
|
|
Prefixing the Path
|
|
|
|
{: .subtitle }
|
|
|
|
|
|
|
|
![AddPrefix](../assets/img/middleware/addprefix.png)
|
|
|
|
|
|
|
|
The AddPrefix middleware updates the URL Path of the request before forwarding it.
|
|
|
|
|
|
|
|
## Configuration Examples
|
|
|
|
|
|
|
|
??? example "File -- Prefixing with /foo"
|
|
|
|
|
|
|
|
```toml
|
2019-03-14 08:30:04 +00:00
|
|
|
[http.middlewares]
|
|
|
|
[http.middlewares.add-foo.AddPrefix]
|
2019-02-26 13:50:07 +00:00
|
|
|
prefix = "/foo"
|
|
|
|
```
|
|
|
|
|
|
|
|
??? example "Docker -- Prefixing with /bar"
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
a-container:
|
|
|
|
image: a-container-image
|
|
|
|
labels:
|
2019-03-14 08:30:04 +00:00
|
|
|
- "traefik.http.middlewares.add-bar.addprefix.prefix=/bar"
|
2019-02-26 13:50:07 +00:00
|
|
|
```
|
|
|
|
|
2019-03-19 15:44:06 +00:00
|
|
|
??? example "Kubernetes -- Prefixing with /bar"
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
apiVersion: traefik.containo.us/v1alpha1
|
|
|
|
kind: Middleware
|
|
|
|
metadata:
|
|
|
|
name: addprefix
|
|
|
|
spec:
|
|
|
|
addprefix:
|
|
|
|
prefix: /bar
|
|
|
|
```
|
|
|
|
|
2019-02-26 13:50:07 +00:00
|
|
|
## Configuration Options
|
|
|
|
|
|
|
|
### prefix
|
|
|
|
|
|
|
|
`prefix` is the string to add before the current path in the requested URL. It should include the leading slash (`/`).
|