Traefik ReplacePath 文档
ReplacePath
replacePath 中间件会:
- 将当前路径替换为指定的路径
- 将原始路径存储在
X-Replaced-Path头中
配置示例
结构化(YAML)
yaml
# 将路径替换为 /foo
http:
middlewares:
test-replacepath:
replacePath:
path: "/foo"结构化(TOML)
toml
# 将路径替换为 /foo
[http.middlewares]
[http.middlewares.test-replacepath.replacePath]
path = "/foo"Labels
yaml
# 将路径替换为 /foo
labels:
- "traefik.http.middlewares.test-replacepath.replacepath.path=/foo"Tags
json
// 将路径替换为 /foo
{
// ...
"Tags" : [
"traefik.http.middlewares.test-replacepath.replacepath.path=/foo"
]
}Kubernetes
yaml
# 将路径替换为 /foo
apiVersion: traefik.io/v1alpha1
kind: Middleware
metadata:
name: test-replacepath
spec:
replacePath:
path: "/foo"配置选项
path
| 字段 | 描述 |
|---|---|
path | path 选项定义在请求 URL 中用作替换的路径。 |
在生产环境使用 Traefik OSS?
如果你在工作中使用 Traefik,可以考虑为其添加企业级 API 网关能力或获取 Traefik OSS 的商业支持。