Web serving & caching
Nginx & reverse proxies
Almost every web request you will ever debug passes through a reverse proxy, and the most common one is Nginx. Interviewers use it to test whether you understand HTTP in practice: how a request is matched to a server and location, how it is passed to backends, what the timeouts and buffers do, and how to read a 502 or 504 from the error log. This topic covers the process model, the configuration language, proxying and load balancing, TLS, rate limiting and caching, Nginx inside Kubernetes (including the retirement of the community ingress-nginx controller), and the alternatives you should be able to compare.
After this topic you can
- Explain what a reverse proxy does and how Nginx handles many connections
- Route requests with server and location blocks and proxy them to backends
- Debug 502, 504 and 413 errors from the logs and plan a move off ingress-nginx
Lessons
-
1How Nginx works
- What a reverse proxy does
- Master and worker processes
- The configuration file
-
2Serving and routing requests
- Server blocks and server_name
- Location matching
- Static files and try_files
-
3Reverse proxying and load balancing
- proxy_pass and headers
- Upstreams and balancing methods
- Timeouts, buffering and WebSockets
-
4TLS, security and performance
- TLS termination
- Rate limiting and access control
- Caching and compression
-
5Nginx in Kubernetes and debugging
- Ingress controllers and the Gateway API
- Debugging with logs
- Alternatives
-
6Interview questions and model answers
- "What is the difference between a forward proxy and a reverse proxy?"
- "Why does Nginx handle many connections with little memory?"
- "Users get 502s after a deploy. How do you debug it?"
- "502 vs 504?"
- "How does Nginx choose a location block?"
- "Explain the proxy_pass trailing slash."
- "How would you rate-limit a login endpoint?"
- "ingress-nginx is retired. What would you do?"