Skip to main content

Configuring NGINX Ingress for Production Traffic

Configure the NGINX Ingress Controller on Kubernetes for production: host and path routing, TLS with cert-manager, rate limiting, and troubleshooting.

52 Terms

Overview and What You Will Learn

An Ingress Controller is a reverse proxy that runs in your cluster and routes external HTTP and HTTPS traffic to Services based on hostname and path, so many services share one cloud load balancer and one place to terminate TLS. Without one, every exposed Service needs its own load balancer.

In this lab, you will:

  • Deploy the NGINX Ingress Controller with Helm using a production values file
  • Route by path and by host to three demo services
  • Terminate TLS with cert-manager
  • Add rate limiting, security headers and an IP allowlist
  • Debug routing problems with kubectl and the controller logs
Security

The community ingress-nginx project was retired in March 2026 and no longer receives security fixes, and it had serious admission webhook flaws in 2025 (known as IngressNightmare). It remains common in existing clusters and exams, so this guide covers it, but plan a migration for new clusters. Gateway API implementations and vendor-supported NGINX controllers are the usual targets, and the ingress2gateway tool helps convert Ingress resources. Verify the current status before you choose a controller.

Why This Matters in Production

Picture a payments company like Razorpay with dozens of internal services behind one domain. Without Ingress, each service needs its own load balancer IP, its own certificate and its own security rules, which multiplies cost and drift. A single controller gives one entry point, central TLS and uniform policy. It also concentrates risk, because one wrong rule can send payment traffic to the wrong backend or leave an admin service open to the internet.

Core Principles

How Traffic Flows Through the Controller

A request hits the cloud load balancer, reaches an NGINX controller pod, and is routed to a Service by the first matching host and path rule.

flowchart TD U([User request]) --> LB[Cloud load balancer
one external IP] LB --> NG[NGINX controller pods] NG -->|api host, /v1/payments| P[payments-service] NG -->|api host, /v1/dashboard| D[dashboard-service] NG -->|admin host| A[admin-service
allowlisted] classDef user fill:#475569,color:#FFFFFF classDef edge fill:#F97316,color:#FFFFFF classDef ctrl fill:#326CE5,color:#FFFFFF classDef svc fill:#10B981,color:#FFFFFF class U user class LB edge class NG ctrl class P,D,A svc

The Four Pieces You Must Not Confuse

Kubernetes does not ship with an Ingress Controller, so an Ingress resource does nothing until one is installed.

Piece What it is
Ingress Controller The NGINX pods that read rules and proxy traffic
Ingress resource The YAML that defines host and path rules
IngressClass Names which controller handles an Ingress
Annotations Per-Ingress NGINX settings such as timeouts and rate limits

Backends must be Services in the same namespace as the Ingress. Use pathType: Prefix for /v1/payments and everything under it, and Exact for a single path.

Detailed Step-by-Step Practical Lab

The lab needs a cluster with a LoadBalancer implementation, helm and kubectl, and a domain you control for real certificates. On kind or minikube there is no cloud load balancer, so use kubectl port-forward -n ingress-nginx svc/ingress-nginx-controller 8443:443 and point --resolve at 127.0.0.1.

  1. Create a values file with production settings: two replicas with a PodDisruptionBudget, resource requests, the client IP preserved, snippet annotations off, and security headers set centrally:
Bash
cat > ingress-values.yaml << 'EOF'
controller:
replicaCount: 2
minAvailable: 1
allowSnippetAnnotations: false
resources:
requests:
cpu: 100m
memory: 180Mi
limits:
memory: 400Mi
nodeSelector:
kubernetes.io/os: linux
service:
externalTrafficPolicy: Local
addHeaders:
X-Frame-Options: DENY
X-Content-Type-Options: nosniff
Referrer-Policy: strict-origin-when-cross-origin
EOF
  1. Install the controller. Pin a chart version after checking helm search repo ingress-nginx --versions, then read the external IP:
Bash
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm repo update
helm install ingress-nginx ingress-nginx/ingress-nginx \
--namespace ingress-nginx --create-namespace \
-f ingress-values.yaml
kubectl get pods -n ingress-nginx
kubectl get ingressclass
export LB_IP=$(kubectl get svc ingress-nginx-controller -n ingress-nginx \
-o jsonpath='{.status.loadBalancer.ingress[0].ip}')
echo $LB_IP
  1. Deploy three small demo backends. Each one answers with its own name, so you can see where a request landed:
Bash
kubectl create namespace ingress-lab
for pair in payments-service:4000 dashboard-service:8080 admin-service:9000; do
NAME=${pair%%:*}
PORT=${pair##*:}
kubectl create deployment $NAME -n ingress-lab \
--image=hashicorp/http-echo:1.0 --port=$PORT \
-- /http-echo -text="$NAME" -listen=:$PORT
kubectl expose deployment $NAME -n ingress-lab --port=$PORT
done
kubectl get pods,svc -n ingress-lab
  1. Create an Ingress with path-based routing, then test it before DNS exists by pinning the hostname to the load balancer IP:
YAML
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: api-ingress
namespace: ingress-lab
annotations:
nginx.ingress.kubernetes.io/proxy-body-size: "10m"
nginx.ingress.kubernetes.io/proxy-connect-timeout: "30"
nginx.ingress.kubernetes.io/proxy-read-timeout: "60"
spec:
ingressClassName: nginx
rules:
- host: api.devops.in
http:
paths:
- path: /v1/payments
pathType: Prefix
backend:
service:
name: payments-service
port:
number: 4000
- path: /v1/dashboard
pathType: Prefix
backend:
service:
name: dashboard-service
port:
number: 8080
Bash
kubectl apply -f ingress-basic.yaml
kubectl get ingress -n ingress-lab
curl --resolve api.devops.in:80:$LB_IP http://api.devops.in/v1/payments # payments-service
curl --resolve api.devops.in:80:$LB_IP http://api.devops.in/v1/dashboard # dashboard-service
curl -i --resolve api.devops.in:80:$LB_IP http://api.devops.in/unknown # 404 from NGINX
  1. Install cert-manager and create an issuer. Start with the Let's Encrypt staging server, because production has strict rate limits while you debug. Point a DNS A record for api.devops.in at $LB_IP first, since the HTTP-01 challenge needs it:
Bash
helm repo add jetstack https://charts.jetstack.io
helm repo update
helm install cert-manager jetstack/cert-manager \
--namespace cert-manager --create-namespace \
--set crds.enabled=true
kubectl get pods -n cert-manager
YAML
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
name: letsencrypt-staging
spec:
acme:
server: https://acme-staging-v02.api.letsencrypt.org/directory # Swap for the production URL when ready
email: rahul@devops.in
privateKeySecretRef:
name: letsencrypt-staging-key
solvers:
- http01:
ingress:
ingressClassName: nginx

No public domain? Use a self-signed issuer for the lab instead, and expect browser warnings:

YAML
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
name: selfsigned
spec:
selfSigned: {}
  1. Add TLS to the Ingress. cert-manager sees the annotation, requests a certificate, and stores it in the named secret. Use the issuer you created:
Bash
kubectl apply -f cluster-issuer.yaml
kubectl annotate ingress api-ingress -n ingress-lab \
cert-manager.io/cluster-issuer=letsencrypt-staging --overwrite
kubectl patch ingress api-ingress -n ingress-lab --type merge -p \
'{"spec":{"tls":[{"hosts":["api.devops.in"],"secretName":"api-devops-tls"}]}}'
kubectl get certificate -n ingress-lab -w # READY turns True in 1 to 2 minutes
curl -k --resolve api.devops.in:443:$LB_IP https://api.devops.in/v1/payments
Tip

If a certificate stays False, follow the chain: kubectl describe certificate, then certificaterequest, order and challenge. The failing ACME step is named in one of them, and it is usually DNS not pointing at the load balancer.

  1. Add rate limiting. Limits apply per client IP, so they only work if the real client IP reaches NGINX, which externalTrafficPolicy: Local helps with. Then prove it by sending a burst:
Bash
kubectl annotate ingress api-ingress -n ingress-lab --overwrite \
nginx.ingress.kubernetes.io/limit-rps="5" \
nginx.ingress.kubernetes.io/limit-connections="10" \
nginx.ingress.kubernetes.io/limit-burst-multiplier="2"
for i in $(seq 1 60); do
curl -sk -o /dev/null -w "%{http_code}\n" \
--resolve api.devops.in:443:$LB_IP https://api.devops.in/v1/payments
done | sort | uniq -c # a mix of 200 and 503 once the limit is hit
  1. Add a second host for the admin service, restricted to office IPs. In controller versions before 1.10 the annotation is whitelist-source-range. Replace the CIDR with your own:
YAML
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: admin-ingress
namespace: ingress-lab
annotations:
nginx.ingress.kubernetes.io/allowlist-source-range: "10.0.0.0/8,203.0.113.25/32"
spec:
ingressClassName: nginx
rules:
- host: admin.devops.in
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: admin-service
port:
number: 9000
Bash
kubectl apply -f ingress-admin.yaml
curl -i --resolve admin.devops.in:80:$LB_IP http://admin.devops.in/ # 403 from outside the allowlist
  1. Troubleshoot the way you would in production. Check endpoints first, because an Ingress with no ready endpoints returns 503:
Bash
kubectl describe ingress api-ingress -n ingress-lab
kubectl get endpoints payments-service -n ingress-lab
kubectl logs -n ingress-nginx -l app.kubernetes.io/name=ingress-nginx --tail=50
kubectl exec -n ingress-nginx deploy/ingress-nginx-controller -- nginx -t
kubectl get events -n ingress-nginx --sort-by='.lastTimestamp'
  1. Clean up. Delete the Ingresses before the controller so the load balancer is released cleanly:
Bash
kubectl delete namespace ingress-lab
helm uninstall cert-manager -n cert-manager
helm uninstall ingress-nginx -n ingress-nginx

Production Best Practices & Common Pitfalls

Common Mistake

Creating Ingress resources before a controller exists. The API server accepts them without an error, but nothing routes traffic. Confirm with kubectl get pods -n ingress-nginx and kubectl get ingressclass first.

Security

Keep allowSnippetAnnotations off. Snippet annotations let anyone who can create an Ingress inject raw NGINX configuration, and they were central to the 2025 vulnerabilities. Set headers through the controller ConfigMap or Helm values instead.

  • Run at least two controller replicas with a PodDisruptionBudget. One pod is a single point of failure for all external traffic.
  • Set resource requests and limits. A controller without them can be OOM-killed during a spike and drop every route at once.
  • Use externalTrafficPolicy: Local. It preserves the real client IP, which rate limits, allowlists and audit logs depend on.
  • Always set ingressClassName. The old kubernetes.io/ingress.class annotation is deprecated and behaves unpredictably with multiple controllers.
  • Prefer one Ingress per service or team. Smaller resources are easier to review, roll back and debug than one huge shared file.
  • Test with the staging issuer first. Switch to the production Let's Encrypt URL only after the flow works end to end.

Quick Reference & Troubleshooting Commands

Command Description
kubectl get ingress -n NS List Ingresses and their addresses
kubectl describe ingress NAME -n NS Show rules and backend endpoint status
kubectl get ingressclass List installed controllers
kubectl get endpoints SVC -n NS Check a Service has ready pods
kubectl get certificate -n NS Check TLS certificate status
kubectl exec -n ingress-nginx deploy/ingress-nginx-controller -- nginx -t Validate the generated NGINX config
Problem Likely cause Fix
404 from NGINX No host or path match Check the Host header, path and pathType
503 Service Unavailable Service has no ready endpoints Check the selector and the readiness probe
502 Bad Gateway Backend crashed or wrong port Check the pod logs and the Service targetPort
413 Request Entity Too Large Body larger than the limit Raise proxy-body-size
504 Gateway Timeout Slow backend Raise proxy-read-timeout or fix the backend
Certificate stuck False DNS or HTTP-01 challenge failing Describe the Order and Challenge objects

Resources

Velero vs etcd Snapshot: Which Do You Need?

Velero vs etcd Snapshot: Which Do You Need?

Velero and etcd snapshots protect different layers of a Kubernetes cluster. See what each backs up, what each misses, and why most DR needs both.

11 min read•Aug 2026
Istio Ambient vs Linkerd in 2026: Which Mesh?

Istio Ambient vs Linkerd in 2026: Which Mesh?

Istio Ambient cuts the sidecar tax at L4, but L7 adds waypoint hops, and Linkerd stable builds now come from Buoyant. Choose with tests.

11 min read•Aug 2026
Nginx Ingress vs Traefik vs Gateway API in 2026

Nginx Ingress vs Traefik vs Gateway API in 2026

Ingress-NGINX is retired. Compare Traefik and Gateway API controllers as replacements, plus a safe migration plan that avoids outages.

10 min read•Aug 2026
OPA Gatekeeper vs Kyverno: Policy Engine in 2026

OPA Gatekeeper vs Kyverno: Policy Engine in 2026

OPA Gatekeeper vs Kyverno compared for 2026: Rego vs YAML, mutation, reporting, and operations, plus how to pick a Kubernetes policy engine.

10 min read•Aug 2026
Helm vs Kustomize in 2026: Templating vs Patching

Helm vs Kustomize in 2026: Templating vs Patching

Helm vs Kustomize compared for 2026 - templating vs patching, Helm 4's new features, and why most production teams end up running both.

5 min read•Aug 2026
Prometheus vs Datadog vs New Relic: Real Costs

Prometheus vs Datadog vs New Relic: Real Costs

Prometheus, Datadog, and New Relic compared for 2026 - real pricing at scale, hidden cost drivers, and which fits a Kubernetes-heavy stack.

5 min read•Aug 2026
Cluster Autoscaler vs Karpenter for EKS in 2026

Cluster Autoscaler vs Karpenter for EKS in 2026

Cluster Autoscaler vs Karpenter on EKS: scale-up speed, bin-packing, Spot handling, Auto Mode limits and a safe migration path, with v1 NodePool YAML.

11 min read•Aug 2026
GKE vs EKS vs AKS in 2026: Which Fits Your Team?

GKE vs EKS vs AKS in 2026: Which Fits Your Team?

GKE, EKS, and AKS compared for 2026 - control plane pricing, Autopilot vs Karpenter vs Node Auto Provisioning, and which platform actually fits your team.

5 min read•Aug 2026
K3s vs K8s vs MicroK8s: Which Distro in 2026?

K3s vs K8s vs MicroK8s: Which Distro in 2026?

Compare K3s, upstream Kubernetes and MicroK8s on footprint, datastores, HA and updates, and pick the right fit for edge, dev or production.

10 min read•Aug 2026
Canary Deployments with Argo Rollouts & Flagger

Canary Deployments with Argo Rollouts & Flagger

Ship to 5% of users first and auto-rollback on bad metrics: canary deployments on Kubernetes with Argo Rollouts, Flagger, and Gateway API.

11 min read•Jun 2026
OpenTelemetry Explained: Metrics, Logs, Traces

OpenTelemetry Explained: Metrics, Logs, Traces

OpenTelemetry in practice: instrument a Node.js service, run a production Collector, sample traces and link metrics, logs and traces in Grafana.

11 min read•Jun 2026
Kubernetes Cost Optimization Without SLO Risk

Kubernetes Cost Optimization Without SLO Risk

Kubernetes clusters average about 8% CPU use. Cut waste safely with request rightsizing, autoscaling, spot, and OpenCost, keeping SLOs.

11 min read•Jun 2026
ArgoCD vs FluxCD: GitOps for Kubernetes in 2026

ArgoCD vs FluxCD: GitOps for Kubernetes in 2026

ArgoCD vs FluxCD compared for 2026: UI, multi-tenancy, Helm, image automation and pruning risks, with a clear guide to picking your GitOps engine.

10 min read•Jun 2026

Explore More in Kubernetes Networking and Traffic Management

All 6 Topics

Frequently Asked Questions

Is Configuring NGINX Ingress for Production Traffic free to learn on DevOps Network?

Yes - this topic, like everything on DevOps Network, is 100% free with no paywall or sign-up gate.

What does the Configuring NGINX Ingress for Production Traffic topic cover?

Configure the NGINX Ingress Controller on Kubernetes for production: host and path routing, TLS with cert-manager, rate limiting, and troubleshooting.

Found a mistake, an outdated step or a broken link?