如何解决Kubernetes nginx入口重定向没有路径前缀
我有几个应用程序正在尝试为其设置入口,应用程序本身将重定向到其他网址,例如:
app1host:8080/auth/logout?redirect_uri=/
我正在尝试创建一个规则,允许重定向重定向回我的路径,但没有任何成功。
app1host:8080/auth/logout?redirect_uri=/ -> domain.com/app1/auth/logout?redirect_uri=/
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-from
和 proxy-redirect-to
:
nginx.ingress.kubernetes.io/proxy-redirect-from: "http://app1host:8080/"
nginx.ingress.kubernetes.io/proxy-redirect-to: "http://example.com/app1/"
,
我必须自己在应用程序中设置 http 根,现在它可以按预期工作。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。