目标:当nginx入口具有主动重写目标特性时,密钥掩蔽器的部署。
入口根据以下内容重写目标:
rewrite.bar.com/something/重写到rewrite.bar.com/,rewrite.bar.com/something/new重写到rewrite.bar.com/new并添加以下标题:
X-Forwarded-Prefix: /somethingKeycloak门守配置:
#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转发前缀头。当在浏览器中通过向路径添加something/手动更正path时,一切都正常。对身份验证服务器有正确的重定向,回调也是有效的。
当通过在部署中设置基uri来增强网关管理员配置时:
...
- --redirection-url=https://rewrite.bar.com/something/
- --base-uri=/something
...未经授权的请求被正确地重定向到https://rewrite.bar.com/something/oauth/authorize,该请求通过入口重写到https://rewrite.bar.com/oauth/authorize,而https://rewrite.bar.com/oauth/authorize与网关守护者(something/oauth/authorize)中未受保护的授权端点不匹配。它会导致不断的重定向。
问题:是否有任何方法来配置网关,使其添加/something来重定向请求,但并不期望它(代理-基-url)?
发布于 2020-09-10 05:28:45
您可以使用代理重定向注释来完成以下任务: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/oauthhttps://stackoverflow.com/questions/61137555
复制相似问题