What Is a Reverse Proxy - and When You Actually Don't Need One

A reverse proxy is a server that sits in front of your application and accepts requests on its behalf. The client connects to the reverse proxy, the reverse proxy decides which backend should handle the request, forwards it, and relays the response back — so from the outside, your whole system looks like a single host.

The name is backwards-sounding for a reason. A forward proxy acts on behalf of the client (your corporate network's outbound proxy, a VPN exit). A reverse proxy acts on behalf of the server, and the client usually has no idea it exists.

It exists to solve one problem: the public-facing concerns of serving traffic — TLS, routing, retries, rate limits, caching, who gets which backend — are the same no matter what your application does, and you do not want to reimplement them inside every service. The reverse proxy is where you put them once.

That consolidation is also the cost. You have added a hop that every single request passes through, and it can fail, misroute, or lie to your backend about who the client was. Detailed view of fiber optic patch cables connecting to a blue patch panel in a data center.

ConceptReverse proxy
Where it sitsInfrastructure — sits at the network edge, between clients and your application servers, at layer 7 (usually HTTP)
In one sentenceA server that receives client requests and forwards them to one of your backends, so TLS, routing, and traffic policy live in one place instead of in every service.

The 60-Second Answer

A reverse proxy terminates the client connection, picks a backend, and forwards the request — then relays the response back.

The problem it solves: cross-cutting edge concerns (TLS certificates, hostname and path routing, load distribution, rate limiting, caching, request logging) stop being duplicated per service and become one configuration.

The cost it adds: an extra network hop and a new single point of failure in the request path, plus the client's real identity now arrives as a header you have to choose to trust. Debugging gets a layer: a 502 means the proxy could not reach or could not parse the backend, which is a different investigation from a 500.

If you run exactly one application process on one host and serve one hostname, you probably do not need one yet.

How It Actually Works

1. The proxy owns the public listener, not your app

One socket faces the internet

The reverse proxy binds the public ports (typically 80 and 443) and your application binds a private port — localhost, a container network, an internal address. Nothing outside reaches the app directly.

This is the structural move everything else depends on. Because the proxy is the only thing listening publicly, it is the only place that needs a TLS certificate, the only place that needs hardening against malformed requests, and the only place that has to be reachable from outside.

server {
  listen 443 ssl;
  server_name api.example.com;
  location / {
    proxy_pass http://127.0.0.1:8080;
  }
}

⚠️ In production — People configure the proxy and forget to actually close the app's port at the firewall or bind address. If your app still listens on 0.0.0.0:8080, anyone who learns the host's IP can bypass every rule you just wrote — the rate limits, the auth gateway, the TLS requirement. Bind to loopback or a private network, not just 'behind' the proxy by convention.


2. It terminates TLS and speaks plaintext (or re-encrypts) inward

Certificates stop at the edge

The client's TLS handshake completes at the proxy. The proxy decrypts the request, which is what makes everything after this point possible — you cannot route on a URL path or rewrite a header inside an encrypted stream you have not opened.

It then forwards inward either as plaintext over a trusted network, or over a second TLS connection to the backend. The second option costs you CPU and certificate management on every backend; the first costs you confidentiality on the internal hop. Which is correct depends entirely on whether you consider your internal network a trust boundary.

TLS termination is the single most common reason a small team adopts a reverse proxy: certificate renewal becomes one automated job in one place.

⚠️ In production — After termination, your application sees an HTTP request and will happily generate http:// URLs in redirects and absolute links, breaking the user's session back to plaintext. You have to forward the original scheme (X-Forwarded-Proto) and configure your framework to trust it. This bug reliably survives staging and appears the day you launch, because staging was often HTTP end to end.


3. It routes on host, path, and headers

One address, many backends

Once the request is decrypted, the proxy inspects the Host header, the path, sometimes a cookie or method, and maps it to an upstream. api.example.com goes to the API service; /static/* goes to object storage; everything else goes to the web app.

This is what lets one public IP and one certificate serve a system made of many processes, written in different languages, deployed on different schedules. The routing table is the public contract of your system, expressed in one file.

location /api/  { proxy_pass http://api_pool; }
location /ws/   { proxy_pass http://realtime; }
location /      { proxy_pass http://web; }

⚠️ In production — Path-prefix routing silently changes what the backend sees, and the rules for whether the prefix is stripped differ between proxies and even between config forms in the same proxy. A backend that builds links from the request path will produce /api/api/users or lose the prefix entirely. Decide explicitly whether the backend is prefix-aware, and write it down — this is the most common routing bug and it is always a surprise.


4. It distributes across multiple backends and checks their health

Load balancing is routing with arithmetic

When a route points at a pool rather than a single address, the proxy picks one member per request — round robin, least connections, or a hash of some request attribute for stickiness. This is load balancing, and it is a reverse proxy feature rather than a separate category of product.

Health checking is the part that matters operationally. The proxy either probes backends on an interval (active) or marks them down after observing failures on real traffic (passive), and stops sending work to members it believes are dead.

This is also how zero-downtime deploys work without anything clever: bring up new instances, let them pass health checks, drain and remove the old ones.

⚠️ In production — A health check that only confirms the process is listening will keep routing traffic to a backend whose database connection pool is exhausted. A health check that is too thorough will take down your entire pool when a shared dependency hiccups, turning a degraded dependency into a total outage. The useful split is a shallow check for the load balancer and a deep check for your monitoring — not the same endpoint.


5. It rewrites headers, and that is how the backend learns who called

Client identity becomes a header

From the backend's perspective, every request now originates from the proxy's address. The real client IP, the original protocol, and the original host survive only because the proxy adds them as headers — the X-Forwarded-* family, or the standardised Forwarded header.

Your application has to be told to read them. Most frameworks have a trusted-proxy setting that, when configured, makes the request object report the forwarded values instead of the socket values.

# Only meaningful if the request genuinely came through your proxy
client_ip = request.headers.get("X-Forwarded-For", "").split(",")[0].strip()

⚠️ In production — These headers are client-supplied data unless your proxy overwrites them. If your app trusts X-Forwarded-For blindly and an attacker can reach it directly — or your proxy appends rather than replaces — they can spoof their IP and walk straight through IP-based rate limiting, geo rules, and audit logs. Configure the proxy to set the header, not add to it, and tell the framework exactly how many proxies deep it sits.


6. It buffers, times out, and retries — on its own schedule

The hop has its own opinions

The proxy typically reads the full request before forwarding and buffers the response before relaying it, which protects slow backends from slow clients. It enforces its own connect, read, and write timeouts, independent of anything your application believes.

It may also retry a failed request against another backend. For an idempotent GET that is free resilience. For a POST that already reached the backend and timed out on the response, it is a duplicate write.

Every timeout in the chain now has to be ordered deliberately: the proxy's read timeout should generally exceed the backend's own request timeout, so the backend gets to produce its real error instead of the proxy inventing a 504.

⚠️ In production — Response buffering breaks streaming. Server-sent events, chunked progress output, and long-poll endpoints will appear to hang and then deliver everything at once, and the cause is a buffering default three layers away from the code you are staring at. WebSocket and streaming routes need buffering off and timeouts raised, configured per-route rather than globally.


7. It can cache, and it can shed load before your app wakes up

Cheapest requests never reach the backend

Because the proxy sees the full request and response, it can serve a cached response without touching the backend at all, and it can enforce rate limits and connection caps on requests it rejects immediately.

This is the asymmetry that makes edge caching valuable: a request answered at the proxy costs a fraction of one that wakes a worker, opens a database connection, and renders a template. Shedding abusive traffic here means it never consumes the resources you were trying to protect.

The tradeoff is correctness. Any cache introduces a window where the proxy serves content the backend no longer agrees with, and you now need an invalidation story.

⚠️ In production — Caching authenticated responses is the catastrophic version of this mistake — one user's dashboard served to the next visitor. It happens when the cache key ignores the auth cookie or the backend forgets Cache-Control: private on a path that looked static. Default to not caching anything with a session, and make caching opt-in per route rather than blanket-on with exceptions.


8. It becomes the place security policy is enforced

One checkpoint, deliberately

Once all traffic funnels through one component, that component is the natural home for IP allowlists, request size limits, header scrubbing, bot filtering, and sometimes authentication itself — validating a token at the edge so backends can assume an authenticated caller.

The appeal is uniform enforcement: a new service added to the routing table inherits the policy without its author doing anything. That is a real and underrated benefit.

The risk is implicit trust. Backends written on the assumption that 'the proxy already checked' have no defence if anything ever reaches them another way — an internal service call, a misconfigured network policy, a debugging tunnel someone left open.

⚠️ In production — Edge authentication without backend verification creates a system where one network misconfiguration equals total compromise. Treat the proxy's checks as a filter that reduces load and catches the obvious, not as the authorisation boundary. Services should still validate what they act on, even when they expect the edge to have validated it first.

Man analyzing design flowchart on whiteboard in a professional office setting. ## Where You Meet It
  • A small SaaS running a Python or Node application behind nginx or Caddy on a single VM. The proxy does one job that matters: it holds the TLS certificate and renews it automatically, so the application never deals with certificates and can be restarted freely without touching the public listener. This is the most common reverse proxy deployment in existence, and it is often the only feature being used.
  • A monolith being decomposed into services. The proxy's routing table is what makes the migration invisible — /billing/* is moved to a new service by changing one upstream, while every other path still goes to the monolith. Clients, mobile apps, and third-party integrations keep using the same base URL throughout, which is what makes incremental extraction feasible at all.
  • A Kubernetes cluster where an ingress controller is the reverse proxy. It receives external traffic, terminates TLS using certificates from the cluster's secret store, and routes by host and path to services whose pod IPs change constantly. The dynamic-backend problem is the reason this layer exists in the cluster: nothing outside could keep up with the churn.
  • An API in front of an expensive backend — image rendering, report generation, a third-party API you pay per call. The proxy caches successful responses and rate-limits per client key, so a single misbehaving integration cannot exhaust capacity or run up the bill for everyone else. The limits are enforced without a line of application code.
  • A legacy internal application that cannot be modified — no TLS support, no modern auth, hardcoded assumptions about its own URL. A reverse proxy in front of it adds HTTPS, adds SSO at the edge, and rewrites its redirects on the way out. The application stays untouched because touching it is the thing nobody wants to do.

When You Actually Need It

  • You need HTTPS and your application does not handle TLS, or you want certificate renewal to be one automated job rather than a per-service concern.
  • More than one process or service has to be reachable on the same hostname, port, or public IP — a web app plus an API, a monolith plus extracted services, static assets plus dynamic routes.
  • You run more than one instance of the same service and need requests spread across them, with dead instances removed automatically — which is also the prerequisite for deploying without downtime.
  • You want a policy enforced identically across every service: rate limits, request size caps, IP restrictions, consistent access logging. Writing it once at the edge is genuinely cheaper and more reliable than writing it per service.
  • Your backends' addresses change frequently — autoscaling groups, containers, ephemeral pods — and clients cannot be expected to track them. The proxy holds the stable address and resolves the churn behind it.
  • A meaningful share of responses are identical across users and expensive to generate, so serving them from an edge cache removes real load rather than adding an abstraction.

When You Don't

  • You run a single application process serving a single hostname, and your platform already terminates TLS for you — a PaaS, a managed app host, a serverless function behind a provider-managed endpoint. The proxy you would add already exists; adding a second one gives you two routing layers to debug and no new capability. Use the platform's domain and certificate settings instead.
  • Your application is not HTTP. For raw TCP, custom binary protocols, or database connections, an HTTP reverse proxy gives you nothing — it cannot read the request, so it cannot route on it. Use an L4 load balancer or the protocol's own proxy (a database connection pooler, for example), and do not pay for layer 7 you cannot use.
  • You are adding one to 'be ready to scale' while running one backend. You have introduced a single point of failure and a new config surface in exchange for a capability you are not using. Scaling horizontally is a day's work when you actually need it; run one host well, and keep the automated certificate story as the only reason you touch a proxy today.
  • You are reaching for a reverse proxy to solve a per-request problem that belongs in the application — business-rule authorisation, per-user quota tied to database state, request validation against your schema. Edge config is a worse language for this than your application's code, it is harder to test, and it drifts from the logic it is supposed to mirror. Keep domain decisions in the domain.
  • You already have a CDN in front of your origin. It is a reverse proxy, and it is doing TLS, caching, and basic shedding. Adding another layer below it for those same jobs doubles your cache invalidation story and your forwarded-header chain. Add the second layer only when you need origin-side routing the CDN cannot express.
  • Internal service-to-service traffic inside a single trust boundary, where a client library with retries and service discovery is sufficient. Putting a centralised proxy in the path of every internal call makes it a bottleneck and an outage amplifier; a sidecar or a smart client keeps the failure local. Reserve the shared edge proxy for traffic that actually crosses the boundary. Steel framework cabinets housing servers networking devices and cables in contemporary equipped data center

What People Get Wrong

"A reverse proxy makes my app faster."

It adds a hop, which adds latency to every request. It makes your system faster only through specific mechanisms you have to actually enable: caching responses that would otherwise be regenerated, connection reuse to backends, offloading TLS handshakes from application workers, or compressing responses. Install one with a default config and no caching and you have made every request slightly slower, which is usually an acceptable price for what you gained elsewhere — but it is a cost, not a speedup.

"A reverse proxy and a load balancer are different things."

Load balancing is one feature a reverse proxy can perform; the terms overlap heavily and the distinction people usually mean is layer 4 versus layer 7. An L4 load balancer forwards packets or TCP connections without reading the request, so it cannot route on a URL or rewrite a header. An L7 reverse proxy reads the HTTP request, which is what buys routing, caching, and header manipulation — at the cost of terminating the connection and seeing the plaintext. Pick by what you need to inspect, not by the product category.

"Putting a reverse proxy in front of my app makes it secure."

It gives you one place to enforce TLS, limits, and filtering, which is a real improvement over nothing. It does not patch your application, does not fix an injection flaw, and does not protect a backend that remains directly reachable on its own port. The common failure is a team that moves authentication to the edge, stops validating in services, and then exposes a backend through some other path — at which point one network mistake becomes a full breach.

"An API gateway is just a fancy reverse proxy, so I should start with the gateway."

An API gateway is a reverse proxy plus API-specific concerns: key management, per-consumer quotas, request and response transformation, sometimes schema validation and a developer portal. If you have external API consumers you need to meter and version independently, that is the right tool. If you have one web app and one API that your own frontend calls, the gateway's extra surface is configuration you will maintain and not benefit from. Start with the plain proxy and move up when a consumer-management problem actually appears.

Why It Was Built This Way

The design is forced by one constraint: a client has to know a single stable address, while the thing serving it does not get to be stable. Addresses change when you scale, deploy, migrate hosts, or split a service in two. DNS was the original answer and it is a bad one for this — record propagation is slow, clients and intermediaries cache aggressively past the TTL you set, and you get no control over which instance a given client reaches or what happens when it is down. The reverse proxy exists because indirection had to live somewhere the operator fully controls, and the only such place in the request path is a server you run.

The second decision — that it terminates the connection rather than forwarding packets — is where the real trade sits. To route on a URL path, enforce a per-endpoint rate limit, or cache a response, the proxy has to read the request, and to read an HTTPS request it has to be the TLS endpoint. That is a deliberate surrender of end-to-end encryption: the plaintext exists in the proxy's memory, and the client's cryptographic guarantee now ends at a machine the client never chose. Everything a layer 7 proxy can do for you follows from accepting that, and every reason to prefer an L4 load balancer follows from refusing it.

What was traded away is transparency about origin. Once the proxy terminates the connection, the backend's socket tells it only that the proxy called — the client's IP, the original scheme, the original host are gone, surviving only as headers the proxy chooses to add. There was no way to preserve them in the protocol itself, so the industry settled on a convention (X-Forwarded-*, later standardised as Forwarded) that is structurally indistinguishable from client-supplied data. That is why so many reverse proxy bugs are identity bugs: spoofed client IPs, broken redirects to http://, rate limits that count every user as one address. The mechanism did not lose that information by accident — it lost it because terminating the connection is the point, and recovering the information is left to configuration you have to get right.

Related Briefs

What to Read Next

  • forward proxy vs reverse proxy
  • layer 4 vs layer 7 load balancing
  • what is an API gateway
  • how TLS termination works

A reverse proxy is indirection you own, and it earns its place when you have more than one thing behind it or more than one address in front of it. Below that — one process, one hostname, TLS already handled by your platform — it is a hop and a config file you maintain for nothing. The decision is not whether reverse proxies are good; it is whether you currently have the problem that indirection solves, and whether you are prepared to own the client-identity and timeout details it quietly hands you.

댓글

이 블로그의 인기 게시물

What Is a Message Queue - and When You Actually Don't Need One

What Is a Bloom Filter - and When You Actually Don't Need One

When to Use GraphQL Over REST API - and When REST Is Still the Right Call