Kubernetes Ingress — NGINX Routing Rules
Configure NGINX Ingress for path-based routing, TLS termination, rate limiting, and redirects.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: app-ingress
namespace: production
annotations:
nginx.ingress.kubernetes.io/ssl-redirect: 'true'
nginx.ingress.kubernetes.io/rate-limit: '100'
nginx.ingress.kubernetes.io/rate-limit-window: '1m'
nginx.ingress.kubernetes.io/proxy-body-size: '10m'
nginx.ingress.kubernetes.io/cors-allow-origin: 'https://example.com'
cert-manager.io/cluster-issuer: letsencrypt-prod
spec:
ingressClassName: nginx
tls:
- hosts:
- api.example.com
- app.example.com
secretName: app-tls
rules:
- host: api.example.com
http:
paths:
- path: /v1
pathType: Prefix
backend:
service:
name: api-v1
port:
number: 3000
- path: /v2
pathType: Prefix
backend:
service:
name: api-v2
port:
number: 3000
- host: app.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: frontend
port:
number: 80Sponsored
DigitalOcean
Use Cases
- Routing traffic to multiple services via paths
- TLS termination with cert-manager integration
- Rate limiting and CORS configuration at ingress
Tags
Related Snippets
Similar patterns you can reuse in the same workflow.
Kubernetes Deployment Configuration
Production-ready Kubernetes deployment with replicas, resource limits, health checks, and rolling updates.
Best for: Production container orchestration
Nginx Reverse Proxy Configuration
Nginx config to reverse-proxy requests to a backend with WebSocket support and security headers.
Best for: Serving Node.js apps behind Nginx
Nginx Load Balancer Configuration
Nginx upstream load balancer with weighted round-robin, health checks, and failover handling.
Best for: Distributing traffic across multiple app servers
Nginx SSL Setup with Certbot
Bash script to install and configure SSL certificates with Certbot for Nginx with auto-renewal.
Best for: Setting up HTTPS for production websites