What is a proxy server? Forward proxy vs reverse proxy explained

A proxy is a middleman that passes requests on your behalf. A forward proxy speaks for the clients; a reverse proxy speaks for the servers. Here is the difference, what each is used for, and where NGINX fits.

Two middlemen at a counter. On the left, a travel agent books tickets for several customers, so the airline sees only the agent; labelled forward proxy, speaks for the clients. On the right, a hotel front desk takes every guest's request and passes it to housekeeping, kitchen or laundry behind a wall; labelled reverse proxy, speaks for the servers.
Fig. 1 — A forward proxy works for the people asking. A reverse proxy works for the people answering.

When you book a flight through a travel agent, the airline deals with the agent, not with you. When you ask a hotel’s front desk for fresh towels, you never meet the housekeeping team; the desk passes your request along. In both cases, someone stands in the middle and talks on behalf of someone else.

In networking, that middleman is a proxy. This guide explains what a proxy server is, the difference between a forward proxy and a reverse proxy, and why almost every website you visit sits behind one.

What is a proxy server?

A proxy server is a server that receives requests and passes them on to another server, then returns the answer. “Proxy” just means someone acting on another’s behalf, as in “voting by proxy”.

The question that matters is: on whose behalf? That’s the difference between the two kinds.

Two rows. Top row, forward proxy: three laptops inside an office box send requests through a forward proxy at the office's edge, out to the internet and to websites. A note says websites see the proxy, not each laptop. Bottom row, reverse proxy: users on the internet send requests to a reverse proxy at the edge of a company's data centre, which forwards them to three app servers inside. A note says users see the proxy, not each server.
Same middleman idea, opposite sides. A forward proxy hides and controls clients; a reverse proxy hides and protects servers.

Forward proxy: speaks for the clients

A forward proxy sits in front of a group of clients (users’ computers) and sends their requests out to the internet. The websites they visit see the proxy’s address, not each individual computer.

Common uses:

  • Office and school networks. All traffic goes out through one proxy that can block certain sites, scan downloads for malware and keep logs.
  • Caching for a group. If 200 people in an office download the same update, the proxy can fetch it once and share the copy.
  • Privacy and location. VPNs and proxy services hide your real address from the sites you visit, or make you appear to be in another country.

The servers on the internet usually don’t know (or care) that a forward proxy is involved. It’s set up by, and for, the client side.

Reverse proxy: speaks for the servers

A reverse proxy sits in front of a group of servers and receives requests from the internet on their behalf. Users think they’re talking to “the website”, but they’re really talking to the reverse proxy, which passes each request to a server behind it.

This is the one that matters most in system design. A reverse proxy can:

  • Hide your servers. Only the proxy is exposed to the internet; app servers stay on a private network. Attackers can’t reach them directly.
  • Spread the load. Send requests across several servers. (That’s load balancing.)
  • Handle HTTPS. Decrypt incoming traffic once at the edge (“TLS termination”) so servers behind it don’t each manage certificates.
  • Cache answers. Keep copies of common responses and serve them without bothering the servers.
  • Compress responses to make them smaller and faster to send.
  • Route by path. Send /api/ to one set of servers and /images/ to another.
  • Absorb bad traffic. Apply rate limits, block known-bad addresses and survive floods of slow connections.

Popular reverse proxies include NGINX, HAProxy, Envoy, Caddy and Traefik. Cloud load balancers and CDNs are reverse proxies too, run as a service.

Forward vs reverse at a glance

Forward proxy Reverse proxy
Acts on behalf of Clients (users) Servers (your app)
Sits At the edge of the users’ network At the edge of your servers’ network
Hides Who the client is Which server answers
Set up by The users’ organisation, or the user The website’s owner
Typical uses Content filtering, privacy, shared caching Load balancing, HTTPS, caching, security, routing
Examples Corporate web proxy, VPN service NGINX, HAProxy, Envoy, cloud load balancers, CDNs

An easy way to remember it: forward = for the clients going out; reverse = for the servers, traffic coming in.

Reverse proxy vs load balancer vs API gateway

These words overlap, because they’re layers of the same idea:

  • A reverse proxy is the general idea: a middleman in front of servers.
  • A load balancer is a reverse proxy whose main job is spreading requests across copies of a service.
  • An API gateway is a reverse proxy specialised for APIs: routing to many services, checking sign-ins, API keys and rate limits.

One piece of software (NGINX, for example) can play all three roles depending on how it’s configured.

Common misconceptions

“A proxy and a VPN are the same.” Both relay traffic, but a VPN usually encrypts all traffic from your device through a tunnel, while a web proxy typically handles web requests only.

“Reverse proxies are only for big companies.” Even a small site often runs NGINX or Caddy in front of its app for HTTPS and caching. It’s one of the first things added in most setups.

“Adding a proxy makes things slower.” It adds a small hop, but caching, compression and connection reuse often make the whole system faster for users.

Key takeaways

  • A proxy is a middleman that passes requests along on someone’s behalf.
  • A forward proxy speaks for clients: filtering, privacy, shared caching.
  • A reverse proxy speaks for servers: hiding them, load balancing, HTTPS, caching, routing, protection.
  • Load balancers, API gateways and CDNs are all kinds of reverse proxy.
  • Behind a proxy, read the user’s address from headers like X-Forwarded-For, carefully.

Frequently asked questions

What is a proxy server in simple words?

A proxy server is a middleman between you and another server. It receives your request, passes it on, and brings back the answer.

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

A forward proxy works for clients: it sends their requests out to the internet and hides who they are. A reverse proxy works for servers: it receives requests from the internet and passes them to servers it hides behind it.

Is NGINX a reverse proxy?

NGINX is a web server that is very often used as a reverse proxy, load balancer and cache in front of application servers.

Is a load balancer a reverse proxy?

Most load balancers that work at the HTTP level are reverse proxies whose main job is spreading traffic across several servers. Some load balancers work at a lower network level and just forward connections.

Why use a reverse proxy?

To protect and hide your servers, spread load across them, handle HTTPS in one place, cache and compress responses, and route requests to the right service.

Comments

LEAVE A COMMENT
No sign-up. Comments appear after a quick review.