Module 2 · Backend architectureLesson 13 of 886 minBeginner
Reverse proxies
A reverse proxy stands in front of your servers and answers on their behalf. Clients never talk to your servers directly.
Try it
Request a static file and see the proxy answer it alone. Then make API calls and watch them go to different servers, and try "Server restart".
A reverse proxy is a server that sits in front of your app servers. Every request hits the proxy first; the proxy decides what to do with it.
Jobs it often does
- Load balancing: spreads requests across several app servers.
- HTTPS termination: handles encryption and certificates in one place.
- Caching: serves images, CSS and other static files without touching the app.
- Compression: shrinks responses with gzip or brotli.
- Security: hides internal addresses, blocks bad requests, limits request size.
- Routing: sends
/apito one group of servers and/blogto another.
NGINX, HAProxy, Envoy, Caddy and Traefik are common reverse proxies.
Reverse vs forward proxy
The words sound alike, but they face opposite directions:
- A forward proxy acts for clients. Your office network might route your browsing through one to filter sites.
- A reverse proxy acts for servers. Visitors think they're talking to your site; really they're talking to the proxy.
Proxy, load balancer, gateway?
These overlap a lot:
- A load balancer is a reverse proxy focused on spreading traffic.
- An API gateway is a reverse proxy with API features: auth, rate limits, per-client routing.
In interviews, say what job you need done: "a layer 7 proxy that terminates TLS and routes by path". The product name matters less.