What Is a Reverse Proxy?

A reverse proxy sits in front of one or more applications. Visitors connect to the proxy, which decides where to send the request and returns the application’s response.

How a Reverse Proxy Works

For example, one proxy can route app.example.com to an app on port 3000 and docs.example.com to an app on port 8080. The application each request reaches depends on the routing rules.

Two Domains, Two Applications

A single public entry point for two apps
  1. Visitorapp.example.com or docs.example.com
  2. Reverse proxyTerminates HTTPS and checks the requested hostname
  3. UpstreamApp on port 3000 or docs on port 8080

Both DNS names resolve to the reverse proxy. The requested hostname determines which local upstream handles the request.

Public hostnameUpstream
https://app.example.comhttp://127.0.0.1:3000
https://docs.example.comhttp://127.0.0.1:8080

The browser negotiates TLS with the proxy on port 443. The proxy chooses the app by hostname. In this example, the connection between the proxy and each local app uses HTTP.

  1. DNS. Both app.example.com and docs.example.com resolve to the public reverse proxy.
  2. TLS. The proxy presents a certificate valid for the requested hostname and decrypts the incoming HTTPS connection.
  3. Routing. It matches the HTTP host to the app or docs upstream in the table. These loopback hops use HTTP. If upstreams are on other machines, configure upstream encryption as appropriate.

When to Use One

Use a reverse proxy when you want one entry point for several apps, HTTPS in front of a local service, or a single place to configure routing. Load balancing and caching are optional features that depend on your software and configuration.

Forward Proxy vs Reverse Proxy

A forward proxy makes requests on behalf of clients. A reverse proxy receives requests on behalf of servers. The proxy basics guide shows where both sit.

Set Up or Diagnose a Reverse Proxy

Start with the NGINX setup guide, create a starting point with the config generator, or follow the 502 diagnostic checklist.