首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >nginx入口反向代理背后的Keycloak网关

nginx入口反向代理背后的Keycloak网关
EN

Stack Overflow用户
提问于 2020-04-10 09:35:39
回答 1查看 1.5K关注 0票数 4

目标:当nginx入口具有主动重写目标特性时,密钥掩蔽器的部署。

入口根据以下内容重写目标:

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

并添加以下标题:

代码语言:javascript
复制
X-Forwarded-Prefix: /something

Keycloak门守配置:

代码语言:javascript
复制
#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来增强网关管理员配置时:

代码语言:javascript
复制
    ...
    - --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)?

EN

回答 1

Stack Overflow用户

发布于 2020-09-10 05:28:45

您可以使用代理重定向注释来完成以下任务:https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#proxy-redirect

它将将位置标头更改为所需的位置标题。

代码语言:javascript
复制
nginx.ingress.kubernetes.io/proxy-redirect-from: /oauth
nginx.ingress.kubernetes.io/proxy-redirect-to: /something/oauth
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61137555

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档