Search code examples
kubernetesnginxkubernetes-ingressazure-aks

404 when trying to access ingress from postman


I have an ingress controller with two services running behind it. I also have an SSL certificate installed with Lets Encrypt and cert-manager.

For some reason, whenever i make a request to my endpoints, it returns a 404 not found error. For example

http://stefandeboer.com/api/neume-billing-service/Transaction

returns

<html>

<head>
    <title>404 Not Found</title>
</head>

<body>
    <center>
        <h1>404 Not Found</h1>
    </center>
    <hr>
    <center>nginx</center>
</body>

</html>

This is the YAML for my ingress:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    cert-manager.io/cluster-issuer: letsencrypt
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/rewrite-target: /
    nginx.ingress.kubernetes.io/use-regex: "true"
  creationTimestamp: "2023-06-05T22:51:36Z"
  generation: 3
  name: neume-ingress
  namespace: default
  resourceVersion: "1888643"
  uid: 9abf4d0f-3370-4856-b3e2-c555c7042739
spec:
  rules:
  - host: stefandeboer.com
  - http:
      paths:
      - backend:
          service:
            name: neume-user-service
            port:
              number: 80
        path: /api/neume-user-service(/|$)(.*)
        pathType: Prefix
      - backend:
          service:
            name: neume-billing-service
            port:
              number: 80
        path: /api/neume-billing-service(/|$)(.*)
        pathType: Prefix
  tls:
  - hosts:
    - stefandeboer.com
    secretName: tls-secret
status:
  loadBalancer:
    ingress:
    - ip: 20.4.165.91

Both my pods are running in the same namespace:

NAME                                                READY   STATUS    RESTARTS   AGE
neume-billing-service-deployment-769ff6487b-sjk5d   1/1     Running   0          31m
neume-user-service-deployment-5674b4b75d-8zhgp      1/1     Running   0          29m

What could i be doing wrong here?


Solution

  • its looks like that you have miss configuration on your ingress, the host declaration must be part of the same object as the HTTP declaration.

    instead of:

      rules:
      - host: stefandeboer.com
      - http:
    

    you need to do it like this:

       rules:
       - host: stefandeboer.com
         http: