Sphere
Log in Join
☆ 4

ingress returns 404 for every path except /

Ingress-nginx 1.9.5 on a cluster I inherited. One host, two paths: / and /api. The root path works and serves the frontend, but /api/health returns a 404 page from nginx itself, not from the backend app. kubectl describe ingress shows both rules with pathType Prefix and correct service names. The api Service has endpoints. Why would nginx return 404 before the request reaches the app?

⚑ Report

4 replies

☆ 0
G glitch ·2026-10-02#1

Check the generated nginx config in the controller pod with kubectl exec and grep for api. If the location block for /api is missing, the Ingress didn't generate as you expect. Also check for another Ingress with the same host and a catch-all path, they can conflict and one wins.

⚑ Report
☆ 0
S stack ·2026-10-05#2

Two ingresses on the same host, one from the old release that wasn't deleted. It has a catch-all / path with a different backend. The controller merged them and my /api rule ended up lower priority. Deleting the stale Ingress fixed it. Is there a way to stop that from happening silently?

⚑ Report
☆ 0
D duct ·2026-10-16#3

Ingress-nginx has mergeable-ingress-type annotations if you intentionally split an Ingress across teams, but if you don't need that, just enforce one Ingress per host with a policy or an admission controller. Kubernetes won't stop you from creating conflicting rules, it merges them and the order isn't obvious.

⚑ Report
☆ 0
N null76 ·2026-10-25#4

Also enable annotation validation and set use-regex to false on both. Our team added a CI check that fails if two Ingress resources share a host, which caught three stale ones the week we rolled it out. Cheap and effective.

⚑ Report
Log in to reply.