The Plain Picture#
A company receptionist who takes all visitors and sends each to the right department — visitors never walk the corridors themselves.
A neighbourhood corner shop that keeps popular items from the big warehouse, so you don't travel to the warehouse for milk.
The Real Names#
A proxy is a server that sits between a client and a server and passes traffic along.
A forward proxy acts for clients (a company proxy all employees' browsing goes through).
A reverse proxy acts for servers: clients talk to it thinking it is the website, and it forwards to the real servers behind it. nginx is the classic example.
A load balancer is a reverse proxy that spreads requests across many copies of your app (Load Balancing (coming soon)).
A CDN (Content Delivery Network) is a worldwide network of reverse proxies that cache content (Ch 8) close to users. Cloudflare, Akamai, AWS CloudFront.
Under the Hood#
Browser ──HTTPS──▶ CDN edge (Chennai) ──▶ Load balancer ──HTTP──▶ app server 1
cache hit? reply TLS ends here ──HTTP──▶ app server 2
immediately (Ch 11) ──HTTP──▶ app server 3Real evidence — the curl -I https://example.com from Bangalore returned these headers:
server: cloudflare
age: 1068
cf-cache-status: HIT
cf-ray: a42098f34f847f43-MAAserver: cloudflare— a CDN answered, not example.com's own server.cf-cache-status: HIT— served from the CDN's cache.age: 1068— this cached copy is 1,068 seconds old.MAA— the airport code for Chennai: the answer came from a nearby CDN edge, not from the other side of the world (remember the latency table in How Computers Work Ch 6).
The original client IP: behind a proxy, your app sees the proxy's IP as the source. Proxies add
X-Forwarded-For: <client IP> (and X-Forwarded-Proto: https) so the app knows who the real client was — only trust
these headers when they come from your own proxy, since clients can fake them.
Check yourself
3 questionsForward proxy vs reverse proxy?
Show answerHide answer
A forward proxy acts on behalf of clients; a reverse proxy sits in front of servers and acts on their behalf.
What does a CDN do, and why does it make sites faster?
Show answerHide answer
Caches content at servers near users, cutting the round-trip distance.
How does your app learn the real client's IP behind a load balancer?
Show answerHide answer
From the X-Forwarded-For header added by the proxy (trusted only if your own proxy set it).