Forward Proxy vs Reverse Proxy: What's the Difference?

Forward proxy vs reverse proxy explained: who each one works for, what it hides, real uses, and copyable Caddy and Nginx reverse proxy configs for a VPS.

Summarize this post with AI

A 19-minute read, or the key points in about 30 seconds, in the assistant you already use.

Opens in a new tab with the prompt filled in. Nothing passes through this site.

Two servers can run the exact same software, say Nginx or Squid, and one is a forward proxy while the other is a reverse proxy. The code isn't what separates them. The side they work for is.

A forward proxy acts for the people sending requests. A reverse proxy acts for the servers answering them. Mix those up and you'll buy residential IPs when you needed Caddy, or open your app to the internet when you meant to hide it. (If your real question is proxy or VPN, that's a different split, covered in my proxy vs VPN comparison.)

The short answer: a forward proxy hides or controls clients, and a reverse proxy hides and protects servers.

Below is how each one works, where you meet them every day, and a working reverse proxy config you can copy onto a VPS. Every behaviour here comes from the Nginx, Caddy, Cloudflare and MDN documentation. Some links are affiliate links; they don't change your price.

Editorial cover showing a forward proxy guarding a group of laptops on the left and a reverse proxy guarding a server rack on the right, joined by an amber line

What is a forward proxy?

A forward proxy is a server that sits in front of client devices and sends their requests to the internet on their behalf. The website you visit sees the proxy's IP address, not yours.

Cloudflare's learning centre describes it with three machines: your computer, the proxy, and the website's origin server. Without the proxy, your computer talks to the origin directly. With it, your computer talks only to the proxy, and the proxy talks to the origin.

People use forward proxies for three broad reasons, per Cloudflare and MDN:

  • Privacy: the destination sees the proxy's IP, so your own address stays out of its logs
  • Control: a school or office routes all traffic through one proxy and blocks sites it doesn't allow
  • Access: getting to content from a different network or location than your own

The client always knows the proxy exists. You type its host and port into a browser, an app, a scraper or the operating system, or your company pushes it to you with a PAC file. If you've ever followed a guide to set up a proxy in Chrome, Firefox or Windows, you configured a forward proxy.

Every commercial proxy you can buy is a forward proxy. That includes datacenter proxies that route through cloud IPs, residential and mobile proxies, whether they speak HTTP or SOCKS5. Squid, the long-running open-source cache, is the classic self-hosted one.

What is a reverse proxy?

A reverse proxy is a server that sits in front of one or more web servers and receives every request meant for them. It forwards each request to the right backend, collects the answer, and returns it to the visitor.

Cloudflare puts the difference in one line: a forward proxy makes sure no origin server talks directly to a specific client, and a reverse proxy makes sure no client talks directly to the origin server.

The visitor usually has no idea it's there. They type your domain, the DNS points at the reverse proxy, and the proxy decides what happens next. MDN sums it up: forward proxies can hide the identities of clients, and reverse proxies can hide the identities of servers.

You use reverse proxies all day without seeing them. Cloudflare's CDN is one. So is the load balancer in front of most large sites, and the Nginx or Caddy instance in front of almost every self-hosted app.

Forward vs reverse proxy: what's the real difference?

The one question that settles it: whose side is the proxy on?

Diagram comparing a forward proxy placed next to the clients with a reverse proxy placed next to the servers, with the internet between them
A forward proxy stands with the clients. A reverse proxy stands with the servers. The traffic direction is the same.
Forward proxyReverse proxy
Works forClients (users, apps, scrapers)Servers (websites, APIs, apps)
Who configures itThe client sideThe site owner
Who knows it existsThe clientUsually nobody outside
HidesThe client's IPThe origin server's IP
Typical jobsPrivacy, filtering, changing your exit IPTLS, routing, load balancing, caching
Common toolsSquid, commercial proxy networksNginx, Caddy, HAProxy, Traefik, Cloudflare

Here's the part most explanations skip. The request still travels the same way in both cases: from a client towards a server. "Reverse" doesn't mean the traffic runs backwards. It means the proxy faces the other way, guarding the destination instead of the source.

That's also why the same software can play both roles. Squid's own site calls it a caching proxy for the web and a server accelerator, which is reverse-proxy work. Nginx is mostly used as a reverse proxy, but the role comes from where you put it and who points at it.

What does a reverse proxy actually do for your site?

On a real server it does five jobs, all listed in Cloudflare's and MDN's documentation:

  • TLS termination: it handles HTTPS certificates and encryption so your apps can speak plain HTTP on a private port
  • Routing: one public IP, many apps, picked by domain or path (app.example.com goes to one container, n8n.example.com to another)
  • Load balancing: it spreads requests across several copies of an app and stops sending traffic to one that fails
  • Caching and compression: it stores static files and compresses responses so the backend does less work
  • Hiding the origin: visitors only ever see the proxy, so the backend's real address and ports stay private
Diagram of a reverse proxy in front of three backend app servers, with labels for TLS, routing, load balancing and caching
One public entry point handles certificates and routing, so each app stays on a private port.

For a self-hoster, routing and TLS are the big two. Without a reverse proxy, every app needs its own public port and its own certificate setup. With one, you open ports 80 and 443 once and add a line per app.

My take: if you run more than one app on a VPS, a reverse proxy isn't optional. It's the front door.

How do you set up Caddy as a reverse proxy?

Caddy is the easiest way to get a reverse proxy with HTTPS. According to Caddy's reverse proxy quick-start, it fetches and renews a publicly trusted certificate automatically when you give it a domain name, as long as the DNS record points at your server and ports 80 and 443 are open.

Say your app listens on port 9000 on the same machine. The whole Caddyfile is this:

code
app.example.com {
    reverse_proxy localhost:9000
}

Reload Caddy and you have HTTPS on app.example.com, proxied to your app. Running a second app is one more block:

code
app.example.com {
    reverse_proxy localhost:9000
}

n8n.example.com {
    reverse_proxy localhost:5678
}

Caddy also handles two details for you, per its reverse_proxy documentation. It passes the original Host header through and sets X-Forwarded-For, X-Forwarded-Proto and X-Forwarded-Host so your app knows the visitor's IP and that the request came in over HTTPS. And it proxies WebSocket connections without extra config.

One catch worth knowing: Caddy ignores incoming X-Forwarded-* values by default to stop spoofing. If something like Cloudflare sits in front of Caddy, you set the trusted_proxies global option so it believes the real client IP from that layer.

How do you set up Nginx as a reverse proxy?

Nginx needs a little more typing, and it doesn't get certificates on its own (you pair it with a tool such as Certbot). The core is the proxy_pass directive inside a location block, as the Nginx admin guide shows.

nginx
server {
    listen 80;
    server_name app.example.com;

    location / {
        proxy_pass http://127.0.0.1:9000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;

        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
}

Those header lines aren't decoration. The Nginx docs say that by default it rewrites the Host header to the backend's address and sets Connection to close. Many apps then build wrong redirect URLs or log every visitor as 127.0.0.1.

The last three lines are for WebSockets, which real-time apps like n8n's editor rely on. Upgrade and Connection are hop-by-hop headers, so Nginx doesn't pass them along unless you set them explicitly. The nginx.org WebSocket page notes the proxy_http_version line is only needed before version 1.29.7. Leaving it in is harmless on newer releases.

Here's what usually goes wrong: a trailing slash. If proxy_pass includes a path, such as http://127.0.0.1:9000/app/, Nginx replaces the matched part of the request URI with it. Add or drop that slash by accident and every request lands on the wrong path.

Where does a reverse proxy fit on a VPS?

On a typical self-hosting box, the reverse proxy is the only thing listening on the public ports. Everything else hides behind it.

Diagram of a single VPS where a reverse proxy on ports 80 and 443 routes traffic by domain to three private app containers
Only the reverse proxy faces the internet. Apps listen on private ports behind it.

The traffic flows like this: the visitor's browser looks up app.example.com, DNS returns your VPS's IP, the request hits Caddy or Nginx on port 443, and the proxy forwards it to the right container on a local port. The app never touches the internet directly.

That design pairs well with a firewall that only allows SSH, 80 and 443. My steps to secure a VPS cover the firewall rules, plus the Docker port trap that can quietly expose a container even when the firewall says no.

If you'd rather not write proxy configs at all, platforms like Coolify ship a reverse proxy built in. My guide to self-hosting apps with Coolify or Docker on a VPS walks through both routes.

For the server itself, I recommend a Hostinger KVM VPS. A KVM plan gives you full root access, which is what you need to install Caddy or Nginx and bind ports 80 and 443.

Can a reverse proxy replace a forward proxy, or a VPN?

No. They solve problems on opposite ends of the connection.

A reverse proxy on your server does nothing for your own browsing. It can't change the IP a website sees when you visit it, because it isn't in that path. If you need a different exit IP for scraping, testing ads or managing accounts, you need a forward proxy.

A forward proxy can't protect your site either. Visitors never pass through it, so it can't terminate TLS, cache your pages or hide your origin.

VPNs are a third thing again. A VPN tunnels all of a device's traffic at the system level, while a forward proxy usually handles one app or protocol at a time. I compare them in detail in proxy vs VPN: what's the difference, and if you're choosing a forward proxy protocol, read SOCKS5 vs HTTP proxies.

Which one do you need?

Match the job to the side of the connection:

  • You want websites to see a different IP than yours: forward proxy
  • You need to filter or log what a team browses: forward proxy
  • You're scraping and keep getting blocked: forward proxy (the IP type matters more than the protocol)
  • You run apps on a server and want HTTPS on proper domains: reverse proxy
  • You want to hide your server's IP or absorb traffic spikes: reverse proxy, often a CDN such as Cloudflare
  • You run several copies of an app: reverse proxy as a load balancer

Plenty of setups use both. A scraper might send requests out through a forward proxy, collect the data, and serve a dashboard from a VPS behind Caddy. Different jobs, different sides.

Frequently asked questions

Is Cloudflare a forward proxy or a reverse proxy?▾
Cloudflare's CDN is a reverse proxy. When you point your domain's DNS at Cloudflare, visitors connect to Cloudflare's edge, which forwards requests to your origin server and can cache, filter and encrypt along the way.
Is Nginx a forward proxy?▾
Nginx is documented mainly as a web server and reverse proxy. The standard build has no handler for the CONNECT method that browsers use to tunnel HTTPS through a forward proxy, so it's a poor fit for that job. For a self-hosted forward proxy, Squid is the usual pick.
Does a reverse proxy hide my IP address when I browse?▾
No. A reverse proxy hides the server, not the visitor. To change the IP websites see when you browse or scrape, you need a forward proxy or a VPN. For the cheapest kind of forward proxy, see [how datacenter proxies work](/blog/what-is-a-datacenter-proxy).
Do I need a reverse proxy for a single app on a VPS?▾
Not strictly, but it's still the simplest way to get HTTPS on a real domain. Caddy fetches and renews the certificate for you, and adding a second app later becomes a two-line change instead of a new open port.
Is a load balancer the same as a reverse proxy?▾
A load balancer is a reverse proxy with one main job: spreading requests across several backend servers. Most reverse proxies, including Nginx, Caddy and HAProxy, can balance load, but they also handle TLS, routing and caching.
How does my app see the visitor's real IP behind a reverse proxy?▾
Through headers the proxy adds, mainly X-Forwarded-For and the standard Forwarded header. Caddy sets X-Forwarded-For by default, while in Nginx you add it with proxy_set_header. Only trust these headers from proxies you control, because clients can fake them.

If you're putting apps online, start with a reverse proxy on a small VPS and add a forward proxy only when a task needs a different exit IP. Caddy plus one Caddyfile gets you most of the way in an afternoon.

Share