# Nginx 404 error after conifiguring nginx-ingress

**URL:** <https://discuss.kubernetes.io/t/nginx-404-error-after-conifiguring-nginx-ingress/26105>\
**Category:** General Discussions\
**Tags:** development, kubernetes-custom-resources\
**Created:** [November 16, 2023, 3:08pm UTC](https://discuss.kubernetes.io/t/nginx-404-error-after-conifiguring-nginx-ingress/26105 "2023-11-16T15:08:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dave\_Dave](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/dave_dave/32/13678_2.png) [@Dave\_Dave](https://discuss.kubernetes.io/u/Dave_Dave)\
**Post date:** [November 16, 2023, 3:08pm UTC](https://discuss.kubernetes.io/t/nginx-404-error-after-conifiguring-nginx-ingress/26105/1 "2023-11-16T15:08:54Z")

</div>

### Cluster information:

Kubernetes version: 1.26.6  
Cloud being used: aks public cloud  
Installation method: deployment and yaml file via kubectl

I have a dns mapped to an external ip of my aks load balancer, below the load balancer there is a nginx ingress controller that commicate with an ingress for the services in my cluster.

When I try to access to my dns like: mydns/post/test I receive the nginx 404 error. Seems that nginx answer correctly but doesn’found the internal routing mapping.

Below I rewrite all the step for this implementation.

Installation of nginx by this command:

```auto
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.8.2/deploy/static/provider/cloud/deploy.yaml

```

with command:

> kubectl get all -n ingress-nginx

I see this result: [![enter image description here](https://us1.discourse-cdn.com/flex016/uploads/kubernetes/original/2X/1/1287938268ce622634dc28102f1d1b74f780114a.png)](https://i.stack.imgur.com/1DLtP.png)

I create the ingress controlled by nginx with this yaml:

```auto
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: service-ingress
  annotations:
    kubernetes.io/ingress.class: nginx
spec:
  rules:
    - http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: post-service
                port:
                  number: 8080

```

And the post-service:

```auto
apiVersion: v1
kind: Service
metadata:
  name: post-service
spec:
  selector:
    app.kubernetes.io/name: post
  ports:
    - port: 8080
      targetPort: 8080

```

The service communicate with a pod that containt a test endpoint(spring boot app, works  
correctly tested via forward port):

```auto
@RestController
@Slf4j
public class PostController {
    

    @GetMapping("/test")
    String all() {
       
        return "Hello!";
    }

}

```

The dns is type A.

Why I receive the error nginx 404 error ?

thanks

---

<div class="post-metadata">

**Author:** ![fox-md](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/fox-md/32/10613_2.png) [@fox-md](https://discuss.kubernetes.io/u/fox-md)\
**Post date:** [November 27, 2023, 9:14pm UTC](https://discuss.kubernetes.io/t/nginx-404-error-after-conifiguring-nginx-ingress/26105/2 "2023-11-27T21:14:25Z")

</div>

Hi,  
Make sure your default ingress class is set to nginx, otherwise you should specify it in your ingress resource.  
Not sure whether annotation still works: [Ingress | Kubernetes](https://kubernetes.io/docs/concepts/services-networking/ingress/#deprecated-annotation)  
Also worth checking pod logs to make sure traffic is being routed to the nginx controller.
