Dev tools
Reverse Proxy vs Load Balancer: The Difference
Reverse proxy vs load balancer: a reverse proxy fronts your servers, a load balancer shares traffic between them. See the overlap, with examples.
In reverse proxy vs load balancer, the difference is the job each one is defined by. A reverse proxy sits in front of your servers and handles requests on their behalf: it hides them, terminates encryption, caches responses and forwards each request to the right backend. A load balancer sits in front of several identical servers and spreads requests across them, skipping any that have failed. A reverse proxy makes sense even with a single backend server; a load balancer only makes sense with more than one. In practice the two overlap so much that the same software, such as NGINX, usually does both.
This guide explains what is a reverse proxy, what a load balancer adds, reverse proxy vs forward proxy, how the two overlap, worked examples with numbers, an NGINX reverse proxy configuration, a table that sorts out proxy vs reverse proxy vs load balancer and the mistakes that cause bugs in real deployments.
Reverse Proxy vs Load Balancer at a Glance
| Reverse proxy | Load balancer | |
|---|---|---|
| Main job | Stand in front of servers and forward requests for them | Spread requests across multiple servers |
| Needs several backends? | No: useful with one | Yes: pointless with one |
| Typical features | TLS termination, caching, compression, header changes, access rules | Balancing algorithm, health checks, failover |
| Sees HTTP? | Yes (a layer 7 device) | Layer 4 (TCP/UDP) or layer 7 (HTTP) |
| Improves | Security, performance, flexibility | Capacity and availability |
| Example tools | NGINX, Caddy, Apache, HAProxy, Envoy | Cloud load balancers, HAProxy, NGINX, Envoy |
A load balancer that works at layer 7 is a reverse proxy with a particular specialty. That is the key to the whole topic: every HTTP load balancer is a reverse proxy, but not every reverse proxy balances load.
What Is a Reverse Proxy?
What is a reverse proxy? It's a server that accepts requests from clients, forwards them to one or more backend servers and returns the backend's response, so the client talks only to the proxy. NGINX's documentation describes the behaviour directly: it sends the request to a specified proxied server, fetches the response and sends it back to the client.
The client doesn't know, or need to know, which machine produced the answer. That single indirection is useful in many ways:
| What a reverse proxy does | Why it helps |
|---|---|
| Hides the backends | Servers aren't exposed to the internet; only the proxy has a public address |
| Terminates TLS | The proxy handles certificates and encryption; backends can speak plain HTTP internally |
| Caches responses | Repeated requests for the same content never reach the application |
| Compresses and optimises | Shrinks responses on the way out |
| Serves static files | Images, scripts and styles are served quickly without troubling the application |
| Routes by host or path | app.example.com and api.example.com, or /blog and /shop, go to different backends |
| Adds security controls | Rate limiting, IP allow and block lists, request size limits, a web application firewall |
| Rewrites headers | Adds the original client address or a request ID |
| Enables zero-downtime changes | Swap or restart a backend while the proxy keeps accepting connections |
Reverse Proxy vs Forward Proxy
Reverse proxy vs forward proxy is the other half of the vocabulary. They face opposite directions:
| Forward proxy | Reverse proxy | |
|---|---|---|
| Sits in front of | Clients (users) | Servers |
| Acts on behalf of | The user, to reach the internet | The server, to receive requests |
| Who configures it | The user or their organisation | The server owner |
| The other side sees | The proxy's address, not the user's | The proxy's address, not the server's |
| Typical uses | Content filtering, anonymity, corporate access control | Load distribution, TLS, caching, protection |
A company web filter or a VPN-style proxy is a forward proxy: it protects or controls the client side. The proxy in front of a website is a reverse proxy.
NGINX Reverse Proxy Example
A minimal NGINX reverse proxy passes requests to an application listening on port 8000 and tells it the real client address. This follows the pattern in NGINX's documentation:
server {
listen 80;
server_name app.example.com;
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://localhost:8000;
}
}By default NGINX changes two request headers when proxying, Host and Connection, which is why the Host header is set explicitly, so the application sees the name the client used. Proxy buffering is on by default, which means NGINX reads the whole response from the backend before passing it to the client. In Caddy the same idea is one line, reverse_proxy localhost:8000, inside a site block. Our comparison of NGINX vs Caddy explains the trade-offs between the two.
What Is a Load Balancer?
A load balancer shares incoming traffic across a group of servers and checks that each is healthy before sending it work. It exists for two reasons: capacity (one server can't handle all the traffic) and availability (if one fails, the others keep serving). It needs a pool of backends and a rule for choosing among them:
| Algorithm | How it picks | Best for |
|---|---|---|
| Round robin | Takes turns (the default in NGINX) | Similar servers and similar requests |
| Weighted round robin | Gives bigger servers more turns | Mixed hardware |
| Least connections | Sends to the server with fewest active connections | Long or uneven requests |
| IP hash | Same client always goes to the same server | Simple stickiness |
| Hash on a key | Same URL or key goes to the same server | Caches |
A layer 4 load balancer forwards TCP or UDP connections without reading them, which is very fast and works for any protocol. A layer 7 load balancer reads HTTP and can route by path, host or header, which is where it starts to look like a reverse proxy.
How Reverse Proxies and Load Balancers Overlap
The categories blur because the software is the same. NGINX, HAProxy and Envoy all proxy requests and balance them. If you add a second backend to an NGINX reverse proxy, you have a load balancer:
upstream backend {
server backend1.example.com weight=5;
server backend2.example.com;
server 192.0.0.1 backup;
}
server {
location / {
proxy_pass http://backend;
}
}The upstream block defines the pool (the first server gets five times the default weight, and the backup is used only when the others are unavailable) and proxy_pass points at it. Same tool, same proxying, one extra job.
| Situation | What you have |
|---|---|
| NGINX in front of one app server, terminating TLS | A reverse proxy |
| NGINX in front of three identical app servers | A reverse proxy that is also a load balancer |
| A cloud network load balancer passing TCP to servers | A load balancer that isn't a reverse proxy (layer 4) |
| A cloud application load balancer routing by path | A load balancer that is also a layer 7 reverse proxy |
Worked Examples With Numbers
Example 1: One Server, Why Add a Reverse Proxy?
A small web app runs on one server and handles 1,000 requests per second at peak. Of those, 800 are for images, scripts and styles that rarely change. If a reverse proxy serves those from its cache or disk, only the remaining 200 requests per second reach the application, an 80% reduction in application load. TLS also moves to the proxy, so the application code never touches certificates. There's still one backend, so there is nothing to balance, but the proxy has already paid for itself.
Example 2: When a Load Balancer Becomes Necessary
Suppose each application server comfortably handles 200 requests per second, and traffic grows to 500. One server can't cope. You need at least ceil(500 / 200) = 3 servers, and to survive one failing you need a fourth, so 4 servers. Something must share the 500 requests across those four and notice when one stops responding: that is the load balancer. With four healthy servers, each handles about 125 requests per second; if one fails, the three remaining handle about 167 each, still under their limit of 200. Without the health check, a quarter of the requests would be sent to a dead server and fail.
Proxy vs Reverse Proxy vs Load Balancer
Here is how the neighbouring terms fit together.
| Term | Sits in front of | Main purpose | Needs multiple servers? |
|---|---|---|---|
| Forward proxy | Clients | Control or hide client traffic | No |
| Reverse proxy | Servers | Protect, accelerate and route to servers | No |
| Load balancer | Servers | Share load and survive failures | Yes |
| API gateway | API back ends | Authentication, quotas, API policy | No |
| CDN | Servers, globally | Cache content near users | No |
| Ingress controller | A Kubernetes cluster | Route outside traffic to services | Usually |
A CDN is essentially a worldwide network of reverse proxies with caches. An API gateway is a reverse proxy specialised for APIs. An ingress controller is a reverse proxy and load balancer built to run inside a Docker and Kubernetes cluster. The family is one idea applied with different emphasis.
Which Do You Need?
| Your situation | What you need |
|---|---|
| One server, want HTTPS, caching, or clean URLs | Reverse proxy |
| Several identical servers, need to survive a server failure | Load balancer (which can be a reverse proxy with an upstream pool) |
| Different paths or hostnames going to different services | Reverse proxy with routing rules |
| Raw TCP or UDP traffic (databases, games, mail) | Layer 4 load balancer |
| Expose a home server without opening ports | A reverse proxy or tunnel; see Cloudflare Tunnel vs Tailscale |
| Hide backend servers from the internet | Reverse proxy |
| Protect against one client hammering you | Reverse proxy with rate limiting |
Common Mistakes
- Losing the client's real address. Behind a proxy, your application sees the proxy's address unless you pass the original in a header such as
X-Forwarded-FororX-Real-IP, and configure the application to trust it only from the proxy. - Forgetting the Host header. The backend may serve the wrong site or generate wrong links if it doesn't see the original host.
- Buffering streaming responses. Proxy buffering is on by default in NGINX, which delays responses such as server-sent events or large streamed downloads. Turn it off for those routes.
- No health checks. Without them, a balancer keeps sending traffic to a dead server.
- Making the proxy a single point of failure. One proxy in front of many servers just moves the failure point. Run two or use a managed service.
- Exposing backend ports. If servers are reachable directly, the proxy's protection can be bypassed.
- Mismatched timeouts. If the proxy times out before the backend finishes, users get errors while the backend keeps working.
- Sticky sessions as a crutch. Pinning users to a server hides state problems and makes failures louder.
- Assuming they're different products. The same NGINX or HAProxy configuration often covers both roles.
FAQ
What is the difference between a reverse proxy and a load balancer?
A reverse proxy forwards client requests to backend servers on their behalf and adds features like TLS termination, caching and security. A load balancer spreads requests across several servers and removes failed ones. A layer 7 load balancer is a reverse proxy that specialises in balancing.
Is a reverse proxy the same as a load balancer?
No, but they overlap. A reverse proxy works with a single server; a load balancer needs several. Many tools, such as NGINX and HAProxy, can act as both, so one configuration often does the two jobs.
What is a reverse proxy used for?
A reverse proxy is used to hide and protect backend servers, terminate TLS, cache and compress responses, serve static files, route traffic by host or path and apply rate limits. It's common in front of even a single web application.
What is the difference between a forward proxy and a reverse proxy?
A forward proxy sits in front of clients and makes requests for them, for example to filter or hide user traffic. A reverse proxy sits in front of servers and receives requests for them. They face opposite directions.
Can NGINX be both a reverse proxy and a load balancer?
Yes. With proxy_pass it works as a reverse proxy, and pointing proxy_pass at an upstream group of servers turns it into a load balancer with methods such as round robin, least connections and IP hash.