๐ŸŽ‰ Premium Proxies ยท 3-Day Free TrialClaim Now โ†’
Proxy Basic

What Is a Reverse Proxy and How Does It Work?

A reverse proxy sits in front of your web servers to load balance, cache, terminate TLS, and hide your origin. Learn how it works and when to use one.

S SparkProxy 3 10 min read
Share
What Is a Reverse Proxy and How Does It Work?

A reverse proxy is a server that sits in front of your web servers and answers the internet on their behalf, forwarding each request to the right backend and passing the response back. Most production sites run behind one, yet the pattern gets confused with forward proxies, load balancers, and CDNs constantly. This guide covers what a reverse proxy does, how it differs from a forward proxy that sits in front of clients, the software people actually deploy, and when you need one.

What Is a Reverse Proxy?

A reverse proxy is an intermediary that accepts client connections from the public internet and relays them to one or more origin servers on a private network. To the client, the reverse proxy is the website. The browser connects to the proxy's IP address and never learns the address, count, or location of the servers doing the real work.

The word "reverse" marks the direction. A forward proxy stands in front of clients and represents them to the wider internet. A reverse proxy stands in front of servers and represents them to arriving clients. Same intermediary role, opposite side of the conversation. Routing a reverse proxy is one job in a broader family, so if you want the parent concept first, read what is a proxy server.

Under HTTP semantics (RFC 9110), this is the "gateway" role: the proxy acts as the origin server to the client while translating and forwarding to upstream servers behind it. Those origin servers usually live on private ranges like 10.0.0.0/8 or 192.168.0.0/16 and hold no public route at all. Only the proxy is reachable from outside. For how private and public addresses interact in this setup, see how proxy servers and IP addressing work together.

How a Reverse Proxy Works

The request path is short and predictable:

  1. DNS for example.com resolves to the reverse proxy's public IP, not the application server's.
  2. The client opens a TCP and TLS connection to the proxy.
  3. The proxy inspects the request (Host header, URL path, cookies, client IP) and picks a backend using its routing rules.
  4. It opens or reuses a connection to that backend on the private network and forwards the request.
  5. The backend processes it and returns a response to the proxy.
  6. The proxy relays the response to the client on the connection it is still holding open.

Because every request and response crosses this one point, the proxy is the natural place to enforce policy. Encryption, routing, caching, and filtering all happen here before any application code runs. The proxy also rewrites headers so the backend keeps useful context: adding X-Forwarded-For lets your app read the real client IP even though it only ever talks to the proxy over the loopback or private link.

Free trial

Scraping at scale? Skip the blocks.

Fast, unblockable datacentre proxies with unlimited bandwidth.

Reverse Proxy vs Forward Proxy

The two look similar on a diagram but face opposite directions. The difference is which side the proxy represents and whose IP it hides.

DimensionReverse proxyForward proxy
Sits in front ofServers (the origin)Clients (the users)
RepresentsThe server, to arriving clientsThe client, to destination servers
Who deploys itThe site or app operatorThe user, network admin, or a proxy provider
Client setupNone; DNS points at the proxyClient configures the proxy address
HidesBackend server IPs from the publicClient IP from the destination site
Typical jobsLoad balancing, TLS, caching, WAF, CDNAnonymity, geo access, scraping, filtering
Examplesnginx, HAProxy, CloudflareSparkProxy residential and datacenter proxies

You deploy a reverse proxy to protect, scale, and optimize traffic coming in to your servers. You use a forward proxy to control or anonymize traffic going out from your clients. Both can coexist: a company might run a forward proxy for employee web access and a reverse proxy in front of its customer-facing app. For the mirror image of everything on this page, read what is a forward proxy. If you are weighing client-side privacy tools instead, proxy vs VPN covers that comparison.

What a Reverse Proxy Does

Load Balancing

Load balancing spreads incoming requests across several identical backends so no single server carries the whole load. The proxy picks a target with an algorithm: round robin (rotate through servers in order), least connections (send the next request to the least busy backend), IP hash (pin each client to one backend for session affinity), or weighted (give bigger servers a larger share). nginx, HAProxy, Traefik, and Envoy all ship this built in, which is why "put nginx in front of it" usually means reverse proxying and load balancing in one process.

TLS Termination

TLS termination means the proxy performs the HTTPS handshake and decryption, then talks to backends over the private network. The certificate lives in one place instead of on every server, so renewal (an automated Let's Encrypt job, say) happens once for the whole fleet. It also moves the CPU cost of encryption off the application servers. When the internal leg must stay encrypted too, for PCI-DSS or HIPAA workloads on shared networks, you re-encrypt to the backend rather than forwarding plaintext, a setup called end-to-end TLS.

Caching and Compression

A reverse proxy can store backend responses and serve them straight from memory or disk. For static assets and pages that rarely change, that removes the backend round trip entirely. The same layer compresses responses with gzip or Brotli, cutting the bytes on the wire for HTML, CSS, and JSON. Both jobs lower backend load and outbound bandwidth at the same time.

Security and WAF

Since the proxy is the single public entry point, it is where you filter. A Web Application Firewall inspects request contents for SQL injection, cross-site scripting, and path traversal, then blocks them before they reach the app. Rate limiting (nginx's limit_req module, for example) caps abusive clients without any application change. Managed reverse proxies such as Cloudflare and Fastly absorb volumetric DDoS traffic at the edge so it never lands on your servers.

Hiding the Origin

Backends on private IPs cannot be reached directly from the internet, so an attacker can only interact with the hardened proxy, never the application's full network stack. This shrinks the attack surface to one purpose-built component. It also lets you add, remove, or replace servers behind the proxy without ever touching public DNS.

Reverse Proxy vs Load Balancer

These overlap enough that vendor docs blur them, but they are not the same thing. A load balancer solves one problem, traffic distribution. A reverse proxy does that plus everything else at the edge.

CapabilityReverse proxyLoad balancer
Distribute traffic across backendsYesYes (its core job)
TLS terminationYesLayer 7 only
Response cachingYesNo
CompressionYesNo
WAF and request filteringYesNo
Header rewritingYesLimited
Hide origin serversYesSometimes
Examplesnginx, HAProxy, EnvoyAWS NLB, F5 BIG-IP

Most reverse proxies can act as load balancers; most dedicated load balancers cannot act as full reverse proxies. An "Application Load Balancer" like AWS ALB is the fuzzy middle case: it terminates TLS, routes by host and path, and runs WAF rules, so it behaves much like a Layer 7 reverse proxy despite the label.

Common Reverse Proxy Software

SoftwareTypeBest for
nginxSelf-hostedThe default general-purpose reverse proxy and web server
HAProxySelf-hostedHigh-throughput HTTP and TCP load balancing with detailed health checks
TraefikSelf-hostedContainers and Kubernetes with automatic service discovery
EnvoySelf-hostedService-mesh sidecars and L7 routing at scale
CaddySelf-hostedAutomatic HTTPS with the simplest config
Cloudflare / FastlyManaged (CDN)Global edge caching, DDoS, and WAF with no servers to run

nginx is the most common self-hosted choice. A minimal config that balances two backends and terminates TLS looks like this:

upstream app_backend {
    least_conn;
    server 10.0.0.11:3000;
    server 10.0.0.12:3000;
}

server {
    listen 443 ssl;
    server_name example.com;

    ssl_certificate     /etc/letsencrypt/live/example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;

    location / {
        proxy_pass         http://app_backend;
        proxy_http_version 1.1;
        proxy_set_header   Host            $host;
        proxy_set_header   X-Real-IP       $remote_addr;
        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

That block does four jobs at once: it terminates TLS on port 443, balances requests across two backends with least_conn, forwards the real client IP in X-Forwarded-For, and keeps the origin IPs (10.0.0.11 and 10.0.0.12) off the public internet. One gotcha catches people at scale: leave out proxy_http_version 1.1 and nginx falls back to HTTP/1.0, which drops keep-alive and forces a fresh TCP handshake to the backend on every single request. Under load that exhausts ephemeral ports for no reason, so set it explicitly. For choosing the listen port, proxy ports explained covers 80, 443, 8080, and the rest.

When to Use a Reverse Proxy

Reach for one when any of these are true:

  • You run more than one backend. A reverse proxy is the cleanest way to load balance and health-check them behind a single hostname.
  • You want centralized TLS. One certificate, one policy, one renewal job for the whole fleet instead of drift across servers.
  • You need caching or compression without editing application code, to cut backend load and bandwidth.
  • You want a single security chokepoint for WAF rules, rate limiting, and DDoS absorption.
  • You must hide origin servers so attackers can only reach a hardened edge, not your app's private network.

For a small single-server hobby project, a reverse proxy is optional. The moment you scale past one backend, care about uptime, or face real attack traffic, it stops being optional and becomes the standard front door for the whole system.

Frequently asked questions

FAQ

It is a server that stands in front of your web servers and talks to the internet for them. Clients connect to the reverse proxy, which forwards each request to a backend and returns the response, so the real servers stay hidden on a private network.

A forward proxy sits in front of clients and hides the client's IP from the destination site. A reverse proxy sits in front of servers and hides the backend server IPs from clients. They are the same intermediary role facing opposite directions: one represents users going out, the other represents servers receiving traffic in.

No, but they overlap. Load balancing (distributing requests across backends) is one function a reverse proxy performs. A reverse proxy also handles TLS termination, caching, compression, header rewriting, and WAF filtering, which a plain load balancer does not.

Yes. nginx is a web server, reverse proxy, load balancer, and HTTP cache in one binary. Its most common production role is a reverse proxy in front of application servers such as Node.js, Gunicorn, or PHP-FPM, enabled by the proxy_pass directive.

It adds one network hop, typically a few milliseconds. In practice the trade is strongly positive: caching removes backend round trips for static content, TLS termination offloads CPU from app servers, and connection reuse to backends cuts overhead, so most sites get faster overall.

Use one as soon as you run more than one backend, want centralized TLS and caching, or need a single point for security filtering and DDoS protection. For a single small server it is optional; for anything scaling or facing attack traffic it is the standard front door.

Limited-time ยท 50% off

Get 50% off your first month

Premium datacentre proxies with unlimited bandwidth. Use the code at checkout.

Offer ends soon โ€” claim it before it's gone

Claim Discount

About the Author

This guide was written by the SparkProxy Technical Team. SparkProxy builds and operates datacenter, residential, and mobile forward proxy networks plus a Scraping API for large-scale web data collection. Our engineers work on both sides of the proxy relationship every day: the forward proxies that route client traffic out, and the reverse proxy and anti-bot layers that target sites deploy to defend their origins. Questions about proxy architecture? Reach us at support@sparkproxy.io.

Keep reading

Related articles

Proxy Failover and Redundancy: Design for Failure

Proxy Failover and Redundancy: Design for Failure

Proxy failover means moving work off a failing component. Learn the five failure modes, circuit breakers, multi-provider ASN traps, and RTO/RPO for scrapers.

SparkProxyยทProxy Basic
The HTTP CONNECT Method Explained

The HTTP CONNECT Method Explained

The HTTP CONNECT method at wire level: authority-form request lines, 200 Connection Established, 407 and 502 debugging, and why HTTPS resists inspection.

SparkProxyยทProxy Basic