跳到正文
Træfɪk

EncodedCharacters

EncodedCharacters 中间件控制请求路径中允许出现哪些具有歧义的保留编码字符。

使用此中间件时,默认会拒绝可能危险的编码字符,以增强安全性。

配置示例

# Allow encoded slash in the request path.
labels:
  - "traefik.http.middlewares.test-encodedchars.encodedcharacters.allowencodedslash=true"
# Allow encoded slash in the request path.
apiVersion: traefik.io/v1alpha1
kind: Middleware
metadata:
  name: test-encodedchars
spec:
  encodedCharacters:
    allowEncodedSlash: true
# Allow encoded slash in the request path.
- "traefik.http.middlewares.test-encodedchars.encodedcharacters.allowencodedslash=true"
# Allow encoded slash in the request path.
http:
  middlewares:
    test-encodedchars:
      encodedCharacters:
        allowEncodedSlash: true
# Allow encoded slash in the request path.
[http.middlewares]
  [http.middlewares.test-encodedchars.encodedCharacters]
    allowEncodedSlash = true

配置选项

配置这些选项时,请检查后端是否完全符合 RFC 3986。 这样有助于避免 Traefik 和后端对同一 URL 产生不同解释的情况。

字段 说明 默认值 必填
allowEncodedSlash 允许请求路径包含编码后的斜杠(%2F 和 %2f)。 false 否
allowEncodedBackSlash 允许请求路径包含编码后的反斜杠(%5C 和 %5c)。 false 否
allowEncodedSemicolon 允许请求路径包含编码后的分号(%3B 和 %3b)。 false 否
allowEncodedPercent 允许请求路径包含编码后的百分号(%25)。 false 否
allowEncodedQuestionMark 允许请求路径包含编码后的问号(%3F 和 %3f)。 false 否
allowEncodedHash 允许请求路径包含编码后的井号(%23)。 false 否

版权所有 © 头文件软件工作室

文档由 HeadFile Studio 翻译。

Traefik v3.7 中文快照 · 原文版权归 Traefik Labs 及贡献者所有 · MIT 许可证