2019-02-26 13:50:07 +00:00
|
|
|
# Add Prefix
|
|
|
|
|
2021-06-18 22:08:08 +00:00
|
|
|
Prefixing the Path
|
2019-02-26 13:50:07 +00:00
|
|
|
{: .subtitle }
|
|
|
|
|
2021-06-18 22:08:08 +00:00
|
|
|
![AddPrefix](../assets/img/middleware/addprefix.png)
|
2019-02-26 13:50:07 +00:00
|
|
|
|
2021-02-11 13:34:04 +00:00
|
|
|
The AddPrefix middleware updates the path of a request before forwarding it.
|
2019-02-26 13:50:07 +00:00
|
|
|
|
|
|
|
## Configuration Examples
|
|
|
|
|
2019-03-29 11:34:05 +00:00
|
|
|
```yaml tab="Docker"
|
|
|
|
# Prefixing with /foo
|
|
|
|
labels:
|
2019-09-23 15:00:06 +00:00
|
|
|
- "traefik.http.middlewares.add-foo.addprefix.prefix=/foo"
|
2019-03-29 11:34:05 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
```yaml tab="Kubernetes"
|
2019-04-03 12:32:04 +00:00
|
|
|
# Prefixing with /foo
|
2019-03-29 11:34:05 +00:00
|
|
|
apiVersion: traefik.containo.us/v1alpha1
|
|
|
|
kind: Middleware
|
|
|
|
metadata:
|
2019-04-03 12:32:04 +00:00
|
|
|
name: add-foo
|
2019-03-29 11:34:05 +00:00
|
|
|
spec:
|
2019-04-03 12:32:04 +00:00
|
|
|
addPrefix:
|
|
|
|
prefix: /foo
|
2019-03-29 11:34:05 +00:00
|
|
|
```
|
|
|
|
|
2019-10-15 15:34:08 +00:00
|
|
|
```yaml tab="Consul Catalog"
|
|
|
|
# Prefixing with /foo
|
|
|
|
- "traefik.http.middlewares.add-foo.addprefix.prefix=/foo"
|
|
|
|
```
|
|
|
|
|
2019-04-15 16:22:07 +00:00
|
|
|
```json tab="Marathon"
|
|
|
|
"labels": {
|
|
|
|
"traefik.http.middlewares.add-foo.addprefix.prefix": "/foo"
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2019-04-08 15:14:08 +00:00
|
|
|
```yaml tab="Rancher"
|
|
|
|
# Prefixing with /foo
|
|
|
|
labels:
|
2019-09-23 15:00:06 +00:00
|
|
|
- "traefik.http.middlewares.add-foo.addprefix.prefix=/foo"
|
2019-04-08 15:14:08 +00:00
|
|
|
```
|
|
|
|
|
2019-07-22 07:58:04 +00:00
|
|
|
```yaml tab="File (YAML)"
|
|
|
|
# Prefixing with /foo
|
|
|
|
http:
|
|
|
|
middlewares:
|
|
|
|
add-foo:
|
|
|
|
addPrefix:
|
|
|
|
prefix: "/foo"
|
|
|
|
```
|
|
|
|
|
2021-06-18 22:08:08 +00:00
|
|
|
```toml tab="File (TOML)"
|
|
|
|
# Prefixing with /foo
|
|
|
|
[http.middlewares]
|
|
|
|
[http.middlewares.add-foo.addPrefix]
|
|
|
|
prefix = "/foo"
|
|
|
|
```
|
|
|
|
|
2019-02-26 13:50:07 +00:00
|
|
|
## Configuration Options
|
|
|
|
|
2019-04-03 12:32:04 +00:00
|
|
|
### `prefix`
|
2019-02-26 13:50:07 +00:00
|
|
|
|
2019-11-14 09:32:05 +00:00
|
|
|
`prefix` is the string to add before the current path in the requested URL.
|
2021-02-11 13:34:04 +00:00
|
|
|
It should include a leading slash (`/`).
|