How does a reverse proxy differ from a forward proxy? How does a backend behind a proxy get the real client IP and scheme?
Short answer
A forward proxy sits on the client side and goes out to the Internet for the client; the server only sees the proxy. A reverse proxy sits on the server side and receives requests for the backend (TLS, load balancing, cache); the client only sees the proxy, so the proxy must send X-Forwarded-* to the backend.
3 points to say:
- A forward proxy acts for the client (hides client IP, controls egress); a reverse proxy acts for the server (hides backends, TLS, load balancing).
- Without
X-Forwarded-*: the backend logs the wrong IP, redirects tohttp://, builds links with the wrong host. - Read
X-Forwarded-Forfrom the right, skipping trusted proxies; the first entry can be spoofed. Need per-API logic → API gateway.
Keep reading the deep dive
Create a free account to read the full explanation and follow-up questions, mark questions as studied and review them on a schedule.