内部 URL 的入口重写目标



我有一个带有 2 个应用程序的入口控制器,一个只是一个 hello 世界,另一个带有真正的微服务应用程序。 现在当我卷曲我的应用程序时(入口似乎工作正常( curl -v/test -->它给 hello-world curl -v/clus -->它会重定向到我的应用程序(因为应用程序是带有资源/静态/索引.html的 springboot,它在 curl 时被渲染。 它卷曲 -v/clus -->index.html -->预期,但如果我想得到卷曲 -v/v1/心跳 -->它仍然给我索引.html 知道为什么会这样吗? 我认为罪魁祸首是我的 ingress.yaml 重写目标,它总是重定向到根?知道如何解决吗?


apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: test-ingress
namespace: dev
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- http:
paths:
- path: /clus
backend:
serviceName: clus-dev-svc
servicePort: 80
- path: /test
backend:
serviceName: hello-service
servicePort: 80

经过长时间的搜索和研发,终于找到了答案。

apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: test-ingress
namespace: dev
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /$1

spec:
rules:
- http:
paths:
- path: /clus/(.+)
backend:
serviceName: clus-service
servicePort: 80
- path: /test
backend:
serviceName: hello-service
servicePort: 80

最初以为添加正则表达式但没有奏效,最后上面的工作

最新更新