Network security

What Is a Reverse Proxy? How It Works, Uses and NGINX Setup

A reverse proxy is the server the internet actually talks to when it visits your site. It hides your real servers, balances the load, handles encryption and blocks attacks before they arrive.

Cysoro Security TeamPublished · 8 min read
Browservisitor REVERSEPROXYTLS · cache · WAF Server 1 Server 2 Origin IP hidden NETWORK SECURITY Reverseproxy The server the internet sees.
Quick answer

A reverse proxy is a server that sits in front of one or more web servers and forwards client requests to them, then returns the responses. It hides the real servers' IP addresses, balances traffic across them, caches content, handles TLS encryption, and filters attacks — so no client ever talks directly to your origin server.

Key takeaways

  • A reverse proxy sits in front of servers and protects them; a forward proxy sits in front of clients and protects them.
  • Its main jobs are hiding origin servers, load balancing, caching, TLS termination and filtering attacks.
  • NGINX, Apache, Caddy, HAProxy and Cloudflare can all act as reverse proxies — most websites already use one.

When you visit a website, you probably assume you are talking to the server that runs it. Usually you are not. You are talking to a reverse proxy — a middleman that takes your request, decides which real server should handle it, and hands you the answer.

What is a reverse proxy?

A reverse proxy is a server that sits in front of one or more web servers and forwards client requests to those servers, then returns their responses to the client. No client ever communicates directly with the origin server.

The HTTP standard itself defines this role. RFC 9110 calls a reverse proxy a "gateway": an intermediary that acts as an origin server for the outbound connection but translates received requests and forwards them inbound to another server or servers. In plain terms, the reverse proxy pretends to be the website, and the real website hides behind it.

Almost every large site works this way. When you load a popular website, your browser connects to a reverse proxy run by a content delivery network or a load balancer. That proxy may serve the page from its cache without ever contacting the origin server, or it may pick one of many servers behind it to answer. You cannot tell the difference, and you do not need to.

Small sites use reverse proxies too. A single NGINX server in front of a web application, or a Cloudflare account in front of a small business site, is a reverse proxy doing the same job at a smaller scale.

How does a reverse proxy work?

A reverse proxy works by terminating the client's connection, choosing a backend server, opening a second connection to it, and relaying the response back. The client sees only the proxy; the backend sees only the proxy.

Here is what happens when you request a page from a reverse-proxied site:

  1. DNS resolution. Your browser looks up the site's hostname. DNS returns the reverse proxy's address, not the address of any backend server.
  2. Connection and TLS handshake. Your browser connects to the proxy, which presents the site's certificate and completes the TLS handshake. Encryption terminates at the proxy, not at the application server.
  3. Inspection and policy. The proxy reads the request and applies its rules: firewall checks, rate limits, authentication, and routing based on the hostname or path.
  4. Forwarding. The proxy opens its own connection to the chosen backend server and sends the request, usually adding headers that identify the original client, such as X-Forwarded-For and X-Real-IP.
  5. Response. The backend answers the proxy, which may cache the response, compress it, or add security headers, then sends it back to your browser.

The key detail is that there are two separate connections: browser to proxy, and proxy to backend. Because the proxy terminates the first connection, it can inspect, cache, filter and transform traffic that would otherwise pass straight through to the server.

One request through a reverse proxy Browseryour computeror phone HTTPS Reverse proxyTLS, cache, WAF,load balancingpublic IP only Server 1hidden IP Server 2hidden IP Cachefast replies The browser never learns the backend servers exist.The response travels back along the same path: backend → proxy → browser.
How a request flows through a reverse proxy to backend servers. Illustration by Cysoro.

Reverse proxy vs forward proxy: what's the difference?

The difference is who the proxy works for. A forward proxy sits in front of clients and protects them; a reverse proxy sits in front of servers and protects them. The mechanism is the same — a middleman between two parties — but the side it serves is opposite.

Forward proxyReverse proxy
Sits in front ofClients (users)Servers (websites)
ProtectsThe client's identityThe server's identity
Configured byThe client or their networkThe server owner
Client knows it is thereYes, the client points at itNo, it looks like the website
Typical usesContent filtering, anonymity, access controlLoad balancing, caching, security, TLS
ExampleA school or company web filter; a VPNCloudflare, NGINX in front of an app

Cloudflare puts it simply: a forward proxy ensures no origin server ever communicates directly with a specific client, while a reverse proxy ensures no client ever communicates directly with an origin server. A VPN is a forward proxy with the client's traffic encrypted end to end; a CDN is a reverse proxy with caching and security added. Cloudflare's reverse proxy guide walks through both sides with diagrams.

The confusion is understandable because both are called "proxy" and both sit in the middle. Ask one question — whose side is it on? — and the answer is clear.

What is a reverse proxy used for?

Reverse proxies are used for load balancing, hiding origin servers, caching, TLS termination, and filtering attacks. Most production websites use one for several of these jobs at once.

Load balancing. A popular site cannot serve millions of visitors from one server. A reverse proxy spreads incoming requests across a pool of servers, so no single server is overloaded, and if one fails, the others take over. It can also send users to the server geographically closest to them, which shortens load times.

Protection from attacks. With a reverse proxy in place, a website never needs to reveal the IP address of its origin servers. Attackers can only target the proxy, which has far more resources to absorb a DDoS attack than a single server. The proxy can also run a web application firewall that blocks malicious requests before they reach the application.

Caching. A reverse proxy can store copies of content close to users. If someone in Paris visits a site hosted in Los Angeles, the Paris proxy can serve the cached page instead of fetching it across the Atlantic every time. Later visitors get the local copy in milliseconds.

SSL/TLS termination. Encrypting and decrypting traffic for every visitor is computationally expensive. A reverse proxy can handle all TLS work, freeing the application servers to focus on the application. It can also manage certificates in one place instead of on every server.

One public face for many services. A single proxy can route /api/ to one service, /blog/ to another, and the main site to a third, while the outside world sees one domain. It can also compress responses, add security headers, and serve maintenance pages when backends are down.

How do you set up a reverse proxy with NGINX?

The simplest NGINX reverse proxy is a few lines: a server block that listens for requests and a proxy_pass directive that forwards them to your application. NGINX's own documentation describes the pattern in three steps — send the request to a proxied server, fetch the response, and send it back to the client.

Here is a minimal working config that forwards everything on example.com to an app listening on port 3000 of the same machine:

# /etc/nginx/sites-available/example server { listen 80; server_name example.com; location / { proxy_pass http://127.0.0.1:3000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } 1 proxy_passwhere the app lives 2 Host headerso the app sees the realdomain, not 127.0.0.1 3 Client IP headersotherwise every visitorlooks like localhost
A minimal NGINX reverse proxy config, annotated. Fictional domain. Illustration by Cysoro.

The header lines matter. By default, NGINX replaces the Host header with the backend's address and does not pass the client's IP along, so your app would log every visitor as 127.0.0.1 and generate links to the wrong host. The proxy_set_header lines fix that.

After writing the config, test it with nginx -t and reload with nginx -s reload — no restart needed. For several backends, define an upstream group and point proxy_pass at it; NGINX shares requests across the group round-robin by default.

For a simpler setup, Caddy does the same job with a single line: reverse_proxy localhost:8080. And if you do not want to run a server at all, a CDN service such as Cloudflare provides a managed reverse proxy with all of these features included.

Whichever tool you use, the pattern is the same: the proxy owns the public address and the certificate, and the application listens only on a private interface. You can check whether your own site's TLS is set up correctly with the free SSL checker.

What are the risks and downsides of a reverse proxy?

A reverse proxy is a powerful layer, but it is also a single point of failure and a place where mistakes are amplified. If the proxy goes down, every backend behind it disappears, so high-availability setups run at least two proxies.

The biggest security consideration is trust. Because the proxy terminates TLS, it sees your traffic in plain text. That is fine when you run the proxy yourself, but with a hosted proxy you are trusting the provider with unencrypted requests and responses. Choose providers carefully and keep sensitive traffic encrypted end to end where it matters.

Configuration mistakes are the other risk. A proxy that forwards the wrong headers can leak internal addresses, pass attacker-controlled headers to the app, or let clients spoof their IP by sending a fake X-Forwarded-For header.

Your application must only trust forwarding headers from the proxy itself, never from the internet. A proxy also adds latency — usually a millisecond or two, but measurable on the slowest networks — and a misconfigured cache can serve one user's private page to another.

Never trust forwarding headers from clientsYour app should only accept X-Forwarded-For and X-Forwarded-Proto from your own reverse proxy. If it trusts them from anyone, an attacker can fake their IP address and bypass IP-based controls.

Reverse proxy vs load balancer vs CDN vs WAF: what's the difference?

These four terms overlap because a reverse proxy can do all of their jobs. The difference is scope: a reverse proxy is the general role, and the others are specific jobs it can perform.

TechnologyWhat it doesRelation to a reverse proxy
Load balancerSpreads traffic across serversOne job a reverse proxy performs
CDNCaches content at edge locations worldwideA distributed reverse proxy with caching
WAFBlocks malicious HTTP requestsA security filter that runs on a reverse proxy
API gatewayRoutes, authenticates and rate-limits API callsA reverse proxy specialized for APIs
Forward proxyServes clients, hides their identityThe mirror image, not the same thing

In practice, one box does several of these at once. Cloudflare is a CDN, a WAF and a load balancer built on reverse proxies. NGINX is a reverse proxy that can also load-balance and cache.

When vendors use the terms interchangeably, ask which job they mean — the answer is usually "all of them, through a reverse proxy". For a fuller picture of the defenses that sit around a website, see our Snort alternatives guide to the intrusion detection tools that watch the traffic the proxy lets through.

The bottom line

A reverse proxy is the server the internet talks to on your behalf. It hides your real servers, spreads the load, caches content, handles encryption and filters attacks — and it is already part of nearly every website you use.

If you run a website, put a reverse proxy in front of it before you worry about anything else. Start with NGINX or a managed CDN, keep your application on a private interface, and only trust forwarding headers from your own proxy. You can verify the result in seconds with the free security headers checker.

Frequently asked questions

What is a reverse proxy in simple terms?

A reverse proxy is a server that stands in front of your website's real servers and handles all visitor traffic for them. Visitors talk to the proxy, the proxy talks to the servers, and the servers' real addresses stay hidden.

What is the difference between a reverse proxy and a forward proxy?

A forward proxy sits in front of clients and protects the client's identity, while a reverse proxy sits in front of servers and protects the server's identity. A VPN is a forward proxy; a CDN is a reverse proxy.

Is Cloudflare a reverse proxy?

Yes. Cloudflare's CDN acts as a reverse proxy: it sits in front of your origin server, caches content, blocks attacks and handles TLS, so visitors never connect directly to your server.

Do I need a reverse proxy for a small website?

Most small websites benefit from one. A free Cloudflare plan or a single NGINX server gives you TLS, caching and origin hiding with little effort, and it protects your server's real IP address from direct attack.

Can a reverse proxy see my traffic?

Yes. Because a reverse proxy terminates TLS, it decrypts the traffic it forwards. That is fine when you run the proxy yourself, but with a hosted proxy you are trusting the provider with unencrypted requests and responses.

What is the difference between a reverse proxy and a load balancer?

A load balancer is one job a reverse proxy performs: spreading traffic across several servers. A reverse proxy can also cache, terminate TLS, filter attacks and route by path, so load balancing is a subset of what it does.

Sources

  1. Cloudflare — What is a reverse proxy?
  2. NGINX — NGINX Reverse Proxy
  3. Kemp — Understanding the Value of a Reverse Proxy Server
Written & fact-checked byCysoro Security Team

The engineers and analysts who build Cysoro's domain scanner, email-authentication checks and free security tools. We test what we write about every day — SPF, DKIM, DMARC, certificates, look-alike domains and phishing — and check each guide against the relevant standards, government guidance and vendor documentation.

  • Email authentication
  • Phishing & BEC
  • Domain & DNS security
  • Small-business security

Checked against RFC 9110, Cloudflare's reverse proxy guide and NGINX's reverse proxy documentation.

How we write and fact-check →

Free tools for this topic

No account needed.

See where your domain stands

Free for up to 3 domains. No card, no installs.

Start free