I need to rewrite the target only for the root path, but all others paths must work normally.
I tried the following rules, but it doesn't redirect to /somePath. Instead, it goes to the normal root.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ingress-test-web-app-other
spec:
ingressClassName: nginx
tls:
- hosts:
- test.example.com
secretName: tls-example
rules:
- host: test.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: webapp
port:
name: http
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ingress-test-web-app-root
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /somePath
nginx.ingress.kubernetes.io/upstream-vhost: "example.com"
spec:
ingressClassName: nginx
tls:
- hosts:
- test.example.com
secretName: tls-example
rules:
- host: test.example.com
http:
paths:
- path: /
pathType: Exact
backend:
service:
name: webapp
port:
name: http
---
If I try nginx.ingress.kubernetes.io/use-regex: "true"
with path: "/(.+)"
for ingress-test-web-app-other, I get 404 on opening root path.
Is there something I'm missing?