gpt4 book ai didi

keycloak-gatekeeper - nginx 入口反向代理背后的 Keycloak 门卫

转载 作者:行者123 更新时间:2023-12-04 04:13:53 32 4
gpt4 key购买 nike

目标 :当 nginx 入口具有事件重写目标功能时,Keycloak 网守部署。

Ingress 根据以下内容重写目标:

  • rewrite.bar.com/something/重写为 rewrite.bar.com/
  • rewrite.bar.com/something/new重写为 rewrite.bar.com/new

  • 并添加以下标题:
    X-Forwarded-Prefix: /something

    Keycloak 网守配置:
    #deployment.yaml:
    ...
    - name: keycloak-gatekeeper
    image: quay.io/keycloak/keycloak-gatekeeper:9.0.2
    imagePullPolicy: IfNotPresent
    args:
    - --listen=0.0.0.0:3000
    - --discovery-url=https://auth.server.com/auth/realms/realm
    - --client-id={client_id}
    - --client-secret={client_secret}
    - --redirection-url=https://rewrite.bar.com/something/
    - --upstream-url=http://127.0.0.1:8080
    - --skip-upstream-tls-verify=false
    - --skip-openid-provider-tls-verify=false
    - --enable-default-deny=true

    问题 :
    网闸将未经授权的请求重定向到 https://rewrite.bar.com/oauth/authorize?state=00191...但端点在 https://rewrite.bar.com/something/oauth/authorize .网守忽略 X-Forwarded-Prefix header 。通过添加 something/ 在浏览器中手动更正路径时到路径,一切正常。正确重定向到身份验证服务器,回调也有效。

    通过在部署中设置基本 uri 来增强网守配置时:
        ...
    - --redirection-url=https://rewrite.bar.com/something/
    - --base-uri=/something
    ...

    未授权的请求被正确重定向到 https://rewrite.bar.com/something/oauth/authorize由入口重写为 https://rewrite.bar.com/oauth/authorize它与网守 ( something/oauth/authorize ) 中不 protected 授权端点不匹配。它导致不断的重定向。

    问题 : 有没有办法以添加的方式配置网关 /something重定向请求但不期望它(代理基网址)?

    最佳答案

    您可以使用代理重定向注释来完成此操作:https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#proxy-redirect
    它会将位置标题更改为您想要的。

    nginx.ingress.kubernetes.io/proxy-redirect-from: /oauth
    nginx.ingress.kubernetes.io/proxy-redirect-to: /something/oauth

    关于keycloak-gatekeeper - nginx 入口反向代理背后的 Keycloak 门卫,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61137555/

    32 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com