Sub topic 1
Forward and Reverse Proxies in System Design
Prerequisites
Assume you understand client-server communication, HTTP methods and headers, IP addresses, ports, DNS, and the basic purpose of TLS.
What a proxy is and why systems use one
A proxy is an intermediary that receives a request and relays it to another server. It can inspect, modify, allow, deny, cache, or balance traffic before returning the response.
The proxy changes the connection path:
Systems add proxies to centralize network policy, hide internal addresses, distribute traffic, terminate TLS, cache responses, or control access to external services. The proxy becomes another network hop, so it can add latency and become a failure point.
Forward proxies: acting on behalf of clients
A forward proxy represents clients. The client is configured to send outbound requests to the proxy, and the proxy chooses whether and where to forward them. The destination server usually sees the proxy's address rather than the client's address.
Common uses include:
- Restricting which websites or services employees can reach.
- Applying egress rules to prevent unauthorized outbound connections.
- Logging and auditing client access.
- Reusing cached responses for many clients.
A forward proxy must be protected with authentication or network access rules. An open forward proxy can be abused to relay traffic for unknown users.
Reverse proxies: acting on behalf of servers
A reverse proxy represents servers. Clients connect to the proxy as if it were the application, while the proxy forwards requests to one or more private backend servers.
Common uses include:
- Routing requests to different applications.
- Balancing traffic across backend instances.
- Terminating client TLS connections.
- Caching safe responses.
- Hiding backend addresses and enforcing shared security rules.
The backend often needs the original client address and scheme. The proxy can pass these in X-Forwarded-For and X-Forwarded-Proto, but the backend must trust those headers only from a known proxy.
Forward vs reverse: who knows about the proxy
| Proxy type | Represents | Typical configuration |
|---|---|---|
| Forward proxy | The client | Client or network specifies the proxy |
| Reverse proxy | The server | DNS points clients to the proxy |
The key distinction is perspective. In a forward-proxy design, the client deliberately uses an intermediary to reach destinations. In a reverse-proxy design, the destination publishes the intermediary as its public endpoint.
Exercise
Which proxy type should an organization use to restrict employee access to external websites?
Show answer
A forward proxy, because it represents clients and controls their outbound requests.