如何使用请求标头作为Traefik入口控制器的入口点地址的路径变量

我使用traefic 1.7通过kubernate中的Keycloak进行服务认证。 (我已经有了Bearer令牌,只需要通过Keycloak对其进行验证)

我的入口控制器如下:

---
apiVersion: v1
kind: ConfigMap
metadata:
  name: traefik-conf
  namespace: kube-system
data:
  traefik.toml: |
    # traefik.toml
    defaultEntryPoints = ["http"]
    [entryPoints]
      [entryPoints.http]
      address = ":80"
      [entryPoints.my-api]
        address = ":9999"
        [entryPoints.my-api.auth.forward]
          address = "https://keycloak-host/auth/realms/R-1/protocol/openid-connect/userinfo"
          trustForwardHeader = true
    [kubernetes]
    namespaces = ["n1","n2","n3","n4"]
    [respondingTimeouts]
    readTimeout = "120s"
    writeTimeout = "5s"
    idleTimeout = "360s"

问题是我在Keycoak中对于不同的组织有不同的领域。在请求标头中,我有Org-Id,需要放置而不是R-1:

address = "https://keycloak-host/auth/realms/R-${Org-Id}/protocol/openid-connect/userinfo"

有没有一种方法可以从请求中提取标头并将其放置到地址路径中?

wmh071230 回答:如何使用请求标头作为Traefik入口控制器的入口点地址的路径变量

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2976354.html

大家都在问