A reverse proxy forwards requests to backend services; a load balancer selects among eligible targets. The reverse proxy vs load balancer choice is about roles, which can overlap: NGINX can do both. An L4 balancer routes connections, while an L7 HTTP proxy can make request-level decisions. Neither name alone guarantees failover or safe retries.
Reverse proxy vs load balancer: overlapping roles
A reverse proxy is a server-facing entry point. Clients send it requests, and it forwards them to the chosen backend. Load balancing adds a selection rule over a target pool. NGINX’s HTTP guide combines these jobs with an upstream group and a proxy directive.
| Question | Reverse proxy role | Load balancing role |
|---|---|---|
| Main job? | Forward to controlled backend services. | Select an eligible target. |
| How many targets? | One service or several routes can suffice. | A pool supports selection; size alone does not prove redundancy. |
| What does it inspect? | Depends on protocol and configuration. | L4 and L7 make different decisions. |
| What is optional? | TLS handling, caching, and access rules need support and setup. | Health checks, persistence, and algorithm choices depend on the implementation. |
| What can still fail? | The entry point, network, or app. | The selector, all targets, shared state, or spare capacity. |
Why have a reverse proxy?
It can give clients one entry point and centralize routes. Add it for a stated need, not because a drawing has a spare box. A proxy does not by itself block direct access to an origin. That needs an access design and a test of the allowed path.
For reverse proxy vs forward proxy, Cloudflare’s distinction is which side the proxy serves. A forward proxy acts for clients reaching other servers; a reverse proxy acts for backend servers receiving client traffic. This direction matters more than whether the software has “proxy” in its name.
L4 and L7 select different things
At layer 4, the routing unit can be a connection. AWS says its Network Load Balancer uses a flow hash for TCP and keeps each TCP connection on one target for its life. That is not a claim that each HTTP request goes to the least busy server.
At layer 7, the router can inspect HTTP content. An AWS Application Load Balancer checks listener rules, then selects within the matching target group. Its documented default is round robin, with configurable alternatives. The service’s name is not enough to infer the routing algorithm.
Reverse proxy vs API gateway
An API gateway adds API-facing policy and management features to its routing job. AWS API Gateway, for example, describes API traffic management, authorization, and access control. The features you need must exist and be configured; a gateway label is not proof that your API has the right policy.
For API gateway vs load balancer, separate policy from target selection. A reverse proxy vs load balancer vs API gateway diagram can show several jobs that one component may combine.
Choose the topology before another component
For one app, a proxy can forward every matching request to that app. There is no spare backend in that route. For replicas, the same HTTP proxy can select among them. NGINX defaults to weighted round robin for an upstream group.
Replicas also need a state plan. If each instance keeps session data only in its own memory, a request sent to another instance may not find it. Decide how the app shares or routes state; do not infer that a balanced pool solves it.
Two backends behind one proxy still have one frontend process. Plan how clients reach a working entry point when that process or host fails. The local test below does not implement redundant proxies, DNS failover, cloud health checks, or shared state.
Keep runtime choice separate from traffic routing. The Bun production guide covers app compatibility and rollout checks.

Illustrative topology, entry failover needs design.
A tested NGINX example: one target and a pool
We compiled open-source NGINX 1.30.5 from the official source inventory and ran this Linux loopback lab on October 11, 2026. The download page listed stable 1.30.5 and mainline 1.31.6. This is an inventory observation. The test uses one worker and fresh GET connections, without TLS or load generation.
First save this standard-library Python fixture as backend.py. It reports the backend label and the path it actually received. It accepts only the GET behavior shown here; it is not a production app or a POST test.
import json
import sys
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
class Handler(BaseHTTPRequestHandler):
def do_GET(self):
data = json.dumps({'backend': sys.argv[2], 'path': self.path}).encode()
self.send_response(200)
self.send_header('Content-Type', 'application/json')
self.send_header('Content-Length', str(len(data)))
self.end_headers()
self.wfile.write(data)
ThreadingHTTPServer(('127.0.0.1', int(sys.argv[1])), Handler).serve_forever()
Use free local ports, or change all matching ports together. In two terminal sessions, start python3 backend.py 18081 blue and python3 backend.py 18082 green. Wait for each server to start.
Save the following as nginx.conf. Its relative log and PID paths use the prefix supplied when starting NGINX. The trace log records the original request URI, attempted targets, and their statuses; use fake test inputs only.
worker_processes 1;
daemon off;
pid logs/nginx.pid;
error_log logs/error.log warn;
events { worker_connections 64; }
http {
log_format trace '$request_uri $upstream_addr $upstream_status';
access_log logs/access.log trace;
upstream app {
server 127.0.0.1:18081 max_fails=1 fail_timeout=60s;
server 127.0.0.1:18082 max_fails=1 fail_timeout=60s;
}
server {
listen 127.0.0.1:18080;
location /single/ {
proxy_pass http://127.0.0.1:18081;
}
location /pool/ {
proxy_pass http://app/;
proxy_connect_timeout 1s;
proxy_read_timeout 2s;
proxy_next_upstream error timeout;
proxy_next_upstream_tries 2;
}
}
}
In a third terminal, create lab/logs under the current directory. Check the installed version with nginx -v; do not assume your OS package matches this lab. Run the syntax check, then start that same binary:
mkdir -p lab/logs
nginx -p "$PWD/lab/" -c "$PWD/nginx.conf" -t
nginx -p "$PWD/lab/" -c "$PWD/nginx.conf"
Why is NGINX called a reverse proxy?
Here, proxy_pass forwards a client’s request to an app server. Make one fresh local HTTP GET to /single/item?x=1 on port 18080. The fixture returned blue and /single/item?x=1. With no URI in the proxy destination, this ordinary unchanged request keeps its original URI.
Make six fresh GETs to /pool/item?x=1. Our responses were blue, green, blue, green, blue, green. Every backend saw /item?x=1. The URI / in proxy_pass http://app/ replaces the matching /pool/ prefix. This result follows the documented prefix rule, not a guess based on slash style.
To reproduce those requests, run these commands in a fourth terminal after all three processes have started. The proxy bypass is restricted to the loopback address in this local test. Keep each query string quoted so the shell passes it intact.
curl --noproxy 127.0.0.1 'http://127.0.0.1:18080/single/item?x=1'
for attempt in 1 2 3 4 5 6; do
curl --noproxy 127.0.0.1 'http://127.0.0.1:18080/pool/item?x=1'
printf '\n'
done
Check both the label and the path in each JSON response. A frontend access log alone shows the client path, which can differ from the path the app saw. The fixture’s response supplies that second view. Keep the two fields distinct when tracing a route through more than one hop.
This exact trace is one-worker local evidence, not a promise of strict global alternation across workers, connections, or all workloads.

URI illustration of the tested paths.
What happens when a backend fails?
Stop the blue fixture and close its listening process. In our next four pool GETs, each client response was HTTP 200 from green. The first access-log entry listed blue then green, with upstream statuses 502, 200. That entry shows a failed attempt followed by a successful retry inside one client request.
Passive detection is driven by live requests
The test did not run periodic probes. It learned of blue’s failure when a live request tried to connect. Our pool sets max_fails=1 and fail_timeout=60s. The upstream reference defines the latter as both the failure-count window and the period a failed target is treated as unavailable.
Those values are explicit lab choices, not measured recovery time or a recommended production policy. With just one server in an upstream group, NGINX ignores these failure parameters. Without another target, excluding the only server cannot create a failover path.
The timeout values also need careful reading. A connection timeout bounds the connection step. The configured read timeout is a gap between successive upstream reads, not a two-second budget for the whole response. Set and test time limits for the app’s real behavior. A slowly arriving stream and an app that never sends a header are different test cases.
A retry has limits
The pool permits error timeout and caps attempts at two. It does not enable non_idempotent. NGINX normally does not retry POST, LOCK, or PATCH after sending the request upstream unless that option is enabled. A routing rule cannot tell you whether an app already committed a write.
Before changing retry policy, use the app’s idempotency and retry contract. Test what happens when a write succeeds but its response is lost. Do not treat the four successful GETs here as evidence that a payment, order, or other write can safely be repeated.
The proxy reference also states that switching targets is possible only before anything has been sent to the client. A broken stream after response delivery starts cannot simply be repaired with another backend. Test that case separately, along with timeouts and exhausted retries.
Finally, green must have enough capacity to serve the remaining work, and the sole proxy must still be running. No test here measured load, latency, active checks, TLS handling, session state, or frontend failover. Stop all three lab processes when finished; keep the config and logs if you need to explain an observed result.

Conceptual model; backend replicas still share an entry.
A decision checklist for your app
Write down the need before choosing a product or extra hop. These are proposed design checks, not certification rules or a claim that this lab tested every failure.
| Need | Select or check | Evidence to collect |
|---|---|---|
| One HTTP app behind an entry point. | Proxy routes and the direct-origin access plan. | Trace the allowed path and test access restrictions. |
| Several replicas of one app. | Target pool, state model, and spare capacity. | Check routing, state use, and a backend stop under realistic load. |
| Raw TCP connection routing. | L4 support and connection behavior. | Follow one connection and test reconnects. |
| API policy or quotas. | Supported gateway features and the actual rules. | Test permitted and denied cases, not just happy-path routing. |
| Safe recovery from failures. | Retry scope, timeouts, and redundant entry points. | Test lost responses, failed streams, and frontend failure separately. |
Watch the app and its data store as well as the router. More targets do not fix a slow query; the database indexing guide explains that separate task. A request can be routed correctly and still fail or take too long inside the app.
Before rollout, use a small test matrix. Check a normal path, a missing path, a stopped target, and a target that accepts a connection but does not reply. Then check the app’s write and stream cases. Record the expected client status and what counts as a safe result before running each test.
Use the backend’s own view to check host, path, and data boundaries as needed. This lab checks paths only; it does not test forwarded-header trust or public origin access. A test that passes one row cannot stand in for the remaining rows. Choose the next check from the failure you need to rule out.
Keep a small evidence record: frontend request, chosen upstream, backend path, status, and relevant failure log. Avoid storing secrets or real user payloads just to prove routing. Decide what each test supports and what it leaves unknown.
The ByteByteGo video below is a short, publisher-authored overview uploaded on March 13, 2024. It helps frame the roles; current defaults and the local results above rest on primary docs and our test. Its promotional links are not recommendations in this guide.



