Overview
NGINX Ingress Controller manages external access to services in your Kubernetes cluster, providing HTTP and HTTPS routing, load balancing, and TLS termination.Installation
Install the NGINX Ingress Controller using the official manifest:ingress-nginx namespace.
Basic Ingress Configuration
Multiple Host Routing
Route traffic to different services based on the hostname:Path-Based Routing
Path Types
Kubernetes Ingress supports three path matching types:- Exact: Matches the URL path exactly as specified
- Prefix: Matches based on a URL path prefix split by
/ - ImplementationSpecific: Delegates path matching to the ingress controller (enables regex for NGINX)
Single Host with Multiple Paths
Route different paths to different backend services:URL Rewriting
Understanding Rewrite Rules
Thenginx.ingress.kubernetes.io/rewrite-target annotation rewrites the request path before forwarding to the backend.
Regex Capture Groups
For a path like/backend(/|$)(.*):
/backend- Literal prefix to match(/|$)- First capture group$1: matches either/or end of string(.*)- Second capture group$2: captures everything after the prefix
Example
With the annotationnginx.ingress.kubernetes.io/rewrite-target: /$2:
Request: https://exchange.jogeshwar.xyz/backend/api/orders
Rewritten path: /api/orders (the /backend prefix is removed)
Backend receives: GET /api/orders
This is useful when your backend service expects paths without the ingress prefix.
TLS Configuration
Automatic Certificate Management
Integrate with cert-manager for automatic TLS certificate provisioning:cert-manager.io/cluster-issuer annotation tells cert-manager to automatically create and renew certificates using the specified ClusterIssuer.
The
secretName specified in the TLS configuration will be automatically created by cert-manager. The certificate will be stored in this Secret and used by the Ingress Controller for TLS termination.Common Annotations
SSL/TLS
CORS Configuration
Request Size Limits
Custom Timeouts
Verification
Check ingress resources:Best Practices
Use IngressClass
Always specify
ingressClassName: nginx to ensure your Ingress uses the correct controllerTLS Everywhere
Enable TLS for all production endpoints using cert-manager integration
Rate Limiting
Protect your services with rate limiting annotations to prevent abuse
Monitoring
Monitor ingress controller metrics and logs for traffic patterns and errors
Troubleshooting
Ingress Not Working
404 Errors
- Verify the
pathTypematches your routing requirements - Check if rewrite rules are stripping necessary path components
- Ensure backend service is running and accessible
TLS Certificate Issues
Related Components
- cert-manager - Automatic TLS certificate management
- Load Balancers - External load balancer configuration
- Sealed Secrets - Secure secret management for TLS certificates

