0

I'm running a Kubernetes cluster on Azure Kubernetes Service(Aks). Currently, I'm having a service called product-service and I have exposed it to the outside using Nginx Ingress. My current ingress configuration looks like below.

apiVersion: networking.k8s.io/v1
kind: Ingress
    metadata:
    name: my-ingress 
annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/use-regex: "true"
    nginx.ingress.kubernetes.io/enable-cors: "true"
    nginx.ingress.kubernetes.io/cors-allow-origin: "*"

spec:
   rules:
       - host: api.example.com
   HTTP:
        paths:
           - path: /api/products
             pathType: Prefix
             backend:
                 service:
                 name: products-service
                 port:
                    number: 5000

My Problem here is whenever I hit api.example.com/api/products it should return a list of products as a Json response. It's working fine. But when I hit this url api.example.com/api/products/{product_id} the server should get the product id I pass and return the details of that specific product. But whenever I hit that route it returns 404 error. I was trying to find a proper rewrite for this case. But I hadn't any luck so far. Could someone explain a workaround to fix this problem?

  • Hi Pasindu Prabhashitha welcome to S.F. Your question does not contain any debugging steps you have already taken, meaning there are almost infinite reasons why that would not work. What logging have you already examined and what debugging have you already done on your own? Don't put new information in the comments, instead [edit your question](https://serverfault.com/posts/1128978/edit) and include those details there. Good luck – mdaniel Apr 19 '23 at 01:26

0 Answers0