Subj,我试图从Traefik重定向后接收查询参数,以完成我的流程。我期望它开箱即用(如果不指定细节,请求细节将被保留)-但似乎Traefik不能做到这一点,或者我错过了一些东西。
所以,F.E.,最初的请求是
https://company.com/oauth/callback?code=blabla
重定向请求如下(不带code
参数)
https://company.com/blabla/#/oauth/callback
有以下几种类型:
apps-ingress.yaml
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
name: company-platform-apps
spec:
entryPoints:
- http
routes:
- kind: Rule
match: 'Host(${SOME_HOST}) && PathPrefix(`/oauth/callback`)'
middlewares:
- name: auth-redirect
services:
- kind: TraefikService
name: noop@internal
apps-middleware.yaml
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
name: company-platform-apps-stripprefix
spec:
stripPrefix:
prefixes:
- /prefix
---
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
name: auth-redirect
spec:
redirectRegex:
permanent: true
regex: '(http[s]?:\/\/[^\/\s]+)(.*)$'
replacement: '$${1}/blabla/#/oauth/callback'
如果您有任何建议,请不要犹豫,ping,谢谢!
1条答案
按热度按时间nkhmeac61#
我已经找到了解决方案,它更多的是在regex维度上,所以下面的变化带来了预期的行为:
这个
regex
使用3个组- host、path和query参数,所以我们只需要将第三个组和参数添加到replacement
中-就是这样!