Kubernetes nginx ingress重定向没有路径前缀



我有几个应用程序正在尝试设置入口,这些应用程序本身会重定向到其他URL,例如:

app1host:8080/auth/logout?redirect_uri=/

我正在尝试创建一个规则,允许重定向重定向回我的路径,但没有取得任何成功。

app1host:8080/auth/logout?redirect_uri=/ -> domain.com/app1/auth/logout?redirect_uri=/

当前代码将我重定向回根文件夹domain.com/

kind: Ingress
apiVersion: networking.k8s.io/v1beta1
metadata:
name: nginx
namespace: webservices
uid: 96336c73-dcae-4c69-b1d3-0eacf8902173
resourceVersion: '356090'
generation: 63
creationTimestamp: '2021-03-21T09:51:34Z'
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/rewrite-target: /$2
managedFields:
- manager: nginx-ingress-controller
operation: Update
apiVersion: networking.k8s.io/v1beta1
time: '2021-03-21T14:19:21Z'
fieldsType: FieldsV1
fieldsV1:
f:status:
f:loadBalancer:
f:ingress: {}
- manager: dashboard
operation: Update
apiVersion: networking.k8s.io/v1beta1
time: '2021-03-23T22:51:34Z'
fieldsType: FieldsV1
fieldsV1:
f:metadata:
f:annotations:
f:nginx.ingress.kubernetes.io/app-root: {}
f:nginx.ingress.kubernetes.io/rewrite-target: {}
- manager: Mozilla
operation: Update
apiVersion: networking.k8s.io/v1beta1
time: '2021-03-23T23:06:04Z'
fieldsType: FieldsV1
fieldsV1:
f:metadata:
f:annotations:
.: {}
f:kubernetes.io/ingress.class: {}
f:spec:
f:rules: {}
spec:
rules:
- host: domain.com
http:
paths:
- path: /app1(/|$)(.*)
pathType: ImplementationSpecific
backend:
serviceName: app1
servicePort: 8080
- path: /app2(/|$)(.*)
pathType: ImplementationSpecific
backend:
serviceName: app2
servicePort: 8181
status:
loadBalancer:
ingress:
- ip: 192.168.0.250

您是否尝试过使用proxy-redirect-fromproxy-redirect-to:

nginx.ingress.kubernetes.io/proxy-redirect-from: "http://app1host:8080/"
nginx.ingress.kubernetes.io/proxy-redirect-to: "http://example.com/app1/"

我不得不在应用程序中自行设置http根,现在它可以正常工作了。

相关内容

  • 没有找到相关文章

最新更新