Reverse Proxy
A server that sits in front of other servers and receives clients' requests on their behalf, handling encryption, routing, caching, and protection in one place.
A reverse proxy is a server that accepts requests from clients and forwards them to one or more backend servers, then returns the backends' responses as if they were its own. Clients see only the proxy. A forward proxy works the other way around: it sits in front of clients and makes requests to the internet on their behalf, as in a corporate web filter. The reverse proxy represents servers, the forward proxy represents clients.
Putting one component in front of everything lets it do jobs every backend would otherwise duplicate:
- TLS termination. The proxy handles Transport Layer Security and certificates in one place, so backends can speak plain HTTP on a private network.
- Routing. Requests go to different backends by hostname or path, so
/apiand/blogcan be separate services behind one domain. - Load distribution. Spreading requests across several backend instances is Load Balancing, one of the most common reasons to run a proxy.
- Caching and compression. Static responses and cacheable pages can be served from the proxy without touching the backend, following HTTP Caching rules.
- Protection. It can enforce Rate Limiting, filter malicious requests, buffer slow clients so backends aren't tied up, and hide backend addresses.
Common reverse proxies include nginx, HAProxy, Caddy, Envoy, and Traefik. The last of these discovers backends automatically from container labels, which suits Containerization. In Kubernetes the same role is called an ingress. A Content Delivery Network is a reverse proxy distributed around the world, and an API Gateway is a reverse proxy specialized for APIs, adding authentication, quotas, and request transformation.
The proxy hides the client from the backend, which causes predictable trouble. The backend sees every request coming from the proxy's address, so the original client IP has to travel in a header such as X-Forwarded-For, and the backend must trust that header only when it comes from the proxy, or anyone can spoof it. The backend also sees plain HTTP, so generated URLs come out as http:// unless the proxy forwards the original scheme. Timeouts at each layer have to agree, or the proxy gives up on requests the backend is still finishing, and long-lived connections like WebSocket and Streaming Response bodies need explicit support. The proxy is also a single point of failure unless it is itself redundant.
See also3
Man-in-the-Middle Attack
An attack in which someone secretly sits between two parties, reading or altering what they send, and why authentication, not just encryption, is the defense.
Networks & Distribution9 connections
Web Server
The program that listens for HTTP requests and answers them with files or generated pages, from the first one at CERN in 1990 through Apache's long dominance to event-driven servers built to hold many thousands of connections at once.
Web Platform10 connections
Middleware
Functions that sit between an incoming web request and the code that answers it, each able to inspect, change, or end the request, chained in an order that quietly determines how the whole application behaves.
Web Platform8 connections
Linked from8
- API GatewayNetworks & Distribution
An API gateway is the single front door to a set of backend services, handling cross-cutting policy once instead of per-service.
- FirewallNetworks & Distribution
A filter that allows or blocks network traffic by rule, the oldest perimeter defense, and less sufficient on its own than it used to be.
- HTTP Status CodeWeb Platform
The three-digit number at the start of every HTTP response that tells the client, caches, crawlers and monitoring what happened, grouped into five classes by the first digit.
- Man-in-the-Middle AttackNetworks & Distribution
An attack in which someone secretly sits between two parties, reading or altering what they send, and why authentication, not just encryption, is the defense.
- MiddlewareWeb Platform
Functions that sit between an incoming web request and the code that answers it, each able to inspect, change, or end the request, chained in an order that quietly determines how the whole application behaves.
- PortSystems & Tooling
The numeric endpoint a network service listens on, and a scarce shared resource on a developer machine.
- Time to LiveNetworks & Distribution
A limit on how long something may live, counted in hops or seconds, which keeps lost packets from circling forever and tells caches when their copies go stale.
- Web ServerWeb Platform
The program that listens for HTTP requests and answers them with files or generated pages, from the first one at CERN in 1990 through Apache's long dominance to event-driven servers built to hold many thousands of connections at once.