Search⌘ K

Creating an Ingress Resource with the Default Backend

Explore how to create a default backend Ingress resource in Kubernetes that forwards unmatched external requests to a specific service, preventing 404 Not Found errors. Understand the role of default backend in managing traffic that does not match other Ingress rules and practice deploying this configuration.

Non-matching requests

In some cases, we might want to define a default backend. We might want to forward requests that do not match any of the Ingress rules.

Let’s see the following example:

Shell
nohup kubectl port-forward -n ingress-nginx service/ingress-nginx-controller 3000:80 --address 0.0.0.0 > /dev/null 2>&1 &
curl -I -H "Host: acme.com" \
"http://0.0.0.0:3000"

So far, we have two sets of Ingress rules in our cluster. One accepts all requests with the base path /demo. The other forwards all requests coming from the devopstoolkitseries.com domain. The request we just sent does not match either of those rules, so the ...