SteelReed

Search

Search posts, questions…

DevOps & CloudQuestion 17 / 35

Junior

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.

X-Forwarded-For, ProtoClientForward proxycorporate proxy, VPNInternetReverse proxyNginx, EnvoyBackend 1Backend 2

3 points to say:

  1. A forward proxy acts for the client (hides client IP, controls egress); a reverse proxy acts for the server (hides backends, TLS, load balancing).
  2. Without X-Forwarded-*: the backend logs the wrong IP, redirects to http://, builds links with the wrong host.
  3. Read X-Forwarded-For from 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.