traefik/docs/content/middlewares/http/replacepath.md

75 lines
1.5 KiB
Markdown
Raw Normal View History

---
title: "Traefik ReplacePath Documentation"
description: "In Traefik Proxy's HTTP middleware, ReplacePath updates paths before forwarding requests. Read the technical documentation."
---
2019-04-08 15:14:08 +00:00
# ReplacePath
Updating the Path Before Forwarding the Request
{: .subtitle }
2019-09-10 12:40:05 +00:00
<!--
TODO: add schema
-->
2021-02-11 13:34:04 +00:00
Replace the path of the request URL.
## Configuration Examples
2019-04-03 12:32:04 +00:00
```yaml tab="Docker"
2021-02-11 13:34:04 +00:00
# Replace the path with /foo
2019-04-03 12:32:04 +00:00
labels:
2019-09-23 15:00:06 +00:00
- "traefik.http.middlewares.test-replacepath.replacepath.path=/foo"
2019-04-03 12:32:04 +00:00
```
```yaml tab="Kubernetes"
2021-02-11 13:34:04 +00:00
# Replace the path with /foo
2019-04-03 12:32:04 +00:00
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
name: test-replacepath
spec:
replacePath:
path: /foo
```
2019-10-15 15:34:08 +00:00
```yaml tab="Consul Catalog"
2021-02-11 13:34:04 +00:00
# Replace the path with /foo
2019-10-15 15:34:08 +00:00
- "traefik.http.middlewares.test-replacepath.replacepath.path=/foo"
```
```json tab="Marathon"
"labels": {
"traefik.http.middlewares.test-replacepath.replacepath.path": "/foo"
}
```
2019-07-22 07:58:04 +00:00
```yaml tab="File (YAML)"
2021-02-11 13:34:04 +00:00
# Replace the path with /foo
2019-07-22 07:58:04 +00:00
http:
middlewares:
test-replacepath:
replacePath:
path: "/foo"
```
```toml tab="File (TOML)"
# Replace the path with /foo
[http.middlewares]
[http.middlewares.test-replacepath.replacePath]
path = "/foo"
```
## Configuration Options
### General
The ReplacePath middleware will:
2021-02-11 13:34:04 +00:00
- replace the actual path with the specified one.
2019-04-08 15:14:08 +00:00
- store the original path in a `X-Replaced-Path` header.
2019-04-03 12:32:04 +00:00
### `path`
2021-02-11 13:34:04 +00:00
The `path` option defines the path to use as replacement in the request URL.