What is a reverse proxy?

A reverse proxy is a server that stands in front of another server and handles requests on its behalf. The client talks to the proxy and never directly to the origin, the server that holds the application. The proxy passes each request on and returns the answer. A forward proxy stands in front of clients instead.

Section Glossary Updated Describes a position in the request path

How it works

The path of one request through a reverse proxy has four steps.

  1. The client sends a request to the address it knows. That address belongs to the proxy.
  2. The proxy receives the whole request: method, path, headers and body.
  3. The proxy sends a request to the origin server, either unchanged or with changes of its own.
  4. The origin answers the proxy, and the proxy returns the response to the client.

The client sees one server and the origin server sees one client, and in both cases that is the proxy. Because the proxy receives the request itself and opens its own connection to the origin, a proxy for web traffic works at layer 7: it reads HTTP requests, not packets. For HTTPS this means the proxy is where the encrypted connection ends, since a request cannot be read while it is still encrypted.

Reverse proxy vs forward proxy

The two differ in which side they protect from direct contact.

Reverse proxy and forward proxy compared by position and visibility
Stands in front ofWhat the other side sees
Forward proxyclientsthe server sees the proxy, not the client
Reverse proxyserversthe client sees the proxy, not the origin

A reverse proxy can be given other jobs besides forwarding. One is load balancing: spreading requests over several web servers. Load balancing is something a reverse proxy can do, not another name for one. The other jobs are outside this page, which covers only the position and what follows from it. An API gateway is one such role; see WAF vs API gateway.

Proxy server and reverse proxy server

What is a proxy server? It is a server that passes requests between two parties instead of letting them connect directly. A reverse proxy server is that server placed in front of the origin. Reverse proxy servers can be general web server software, a dedicated proxy, or a cloud service.

Software you may already run can take the role: nginx does it through its proxy module, and Apache HTTP Server through mod_proxy. How to configure either is outside this page.

Why it matters

The position decides what can be done with a request. Anything that must judge a request before the application sees it has to stand in the path of that request, and a reverse proxy is exactly such a place. A web application firewall can work from there: it reads each request and decides whether to pass it on or refuse it. Without that position there is no point before the origin at which a request could be refused.

The position is not the defence, though. A proxy that only forwards judges nothing, and the rules are what make it a firewall. The second limit is routing: a request that reaches the origin without passing through the proxy is not seen by it at all.

The same position can be held in the cloud or by a device in your own network. That choice is compared under cloud WAF vs appliance.

The rest of the filtering vocabulary is in this glossary.

Questions

What is the difference between a proxy and a reverse proxy?

A forward proxy acts on behalf of clients and can hide their identities from servers. A reverse proxy acts on behalf of servers and can hide the origin from clients.

Is a reverse proxy the same as a load balancer?

No. Load balancing, spreading requests over several web servers, is one job a reverse proxy can do.

Is a reverse proxy a WAF?

No. A reverse proxy only stands in the request path. It becomes a web application firewall when rules judge the requests it receives.