I have two backend api-services:
- api-service-v1
- api-service-v2
Both respond on "/api/" path
I have this configuration running fine as a docker-compose setup where nginx service serves as a proxy with the following config file
/etc/nginx/conf.d/default.conf:
server {
...
location /apiv1/ {
proxy_pass http://api-service-v1/api/;
}
...
location /apiv2/ {
proxy_pass http://api-service-v2/api/;
}
...
}
Now I'd like to deploy the setup to k8s cluster. I got stuck with ingress configuration. ingress.yml:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: dev-ingress
annotations:
nginx.ingress.kubernetes.io/use-regex: "true"
spec:
rules:
- host: demo.com
http:
paths:
- pathType: Prefix
path: "/"
backend:
service:
name: frontend-service
port:
number: 80
- pathType: Prefix
path: "/apiv1/"
backend:
service:
name: api-service-v1
port:
number: 80
- pathType: Prefix
path: "/apiv2/"
backend:
service:
name: api-service-v2
port:
number: 80
Path "/" works fine. But paths "/apiv1/" and "/apiv2/" do not work.
Please help.
Thanks!