NGINX Ingress Rate Limit Not Working
You encounter a nginx configuration issue that prevents your workflow from completing. This guide walks through the fix step by step.
Wrong ❌
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
nginx.ingress.kubernetes.io/limit-rps: "1000" # Too high to ever trigger
nginx.ingress.kubernetes.io/limit-burst: "100"
# Missing limit-whitelist and limit-conn-per-burst
Wrong Output
Rate limit never triggers. Value too high for practical enforcement.
Right ✅
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
nginx.ingress.kubernetes.io/limit-rps: "100"
nginx.ingress.kubernetes.io/limit-burst: "50"
nginx.ingress.kubernetes.io/limit-conn-per-burst: "10"
nginx.ingress.kubernetes.io/limit-whitelist: "10.0.0.0/8"
spec:
rules:
- host: api.example.com
http:
paths:
- path: /
pathType: Prefix
backend: { service: { name: api-service, port: { number: 80 } } }
Right Output
Rate limit active. 100 req/s with burst of 50. Internal IPs whitelisted.
Prevention
- Set realistic limit-rps values based on API capacity.
- Use limit-burst for short traffic spikes.
- Set limit-conn-per-burst to limit concurrent connections.
- Use limit-whitelist for trusted IP ranges.
- Test with load testing tool.
DodaTech applies similar defensive patterns across Doda Browser, DodaZIP, and Durga Antivirus Pro infrastructure for production reliability.
Common Mistakes with ingress rate limit
- Forgetting
deriving (Show, Eq)on custom data types needed for debugging - Placing the wildcard pattern first in case expressions, making all subsequent patterns unreachable
- Using
headandtailinstead of pattern matching, causing runtime errors on empty lists
These mistakes appear frequently in real-world NGINX code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.
Practice Exercise
Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.
This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.
FAQ
This quick fix is part of the DodaTech infrastructure engineering series. Learn more at DodaTech tutorials.
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro