Sub topic 4
Forward vs reverse: who knows about the proxy
This chapter assumes you know HTTP requests, headers and methods, what IP addresses, ports and DNS do, and what TLS provides. It compares forward and reverse proxies along one question: which party knows the proxy exists, and which party chose to put it there. That question explains most of the differences in configuration, security and failure behavior.
The core distinction
Both kinds of proxy sit between a client and a server and relay requests. They differ in whose interests they serve.
- A forward proxy acts for clients. The client (or the client's network) is configured to use it. The origin server sees the proxy's address, not the client's.
- A reverse proxy acts for servers. The server operator places it in front of one or more backends. The client believes it is talking to the origin itself, and the backend addresses stay hidden.
Put another way, a forward proxy hides clients from servers, and a reverse proxy hides servers from clients.
A single request can pass through both. A user in an office reaches a website through the company's forward proxy, and the website's operator receives it at a reverse proxy. Neither proxy needs to know about the other.
Who knows about the proxy
The two kinds differ in what each party knows.
| Question | Forward proxy | Reverse proxy |
|---|---|---|
| Who operates it? | The client's organization or ISP | The server's operator |
| Who chose to use it? | The client side (or the network, if transparent) | The server side |
| Does the client know it exists? | Usually yes, because it is configured. Not with a transparent deployment. | Usually no. The client sees one hostname. |
| Does the origin server know? | Not necessarily. It sees the proxy as the client. | Yes. The backend is configured to sit behind it. |
| What does the origin see as the client address? | The proxy's address | The reverse proxy's address, unless forwarding headers are used |
| What does DNS point to? | The client resolves the target name, or the proxy does | The public name points to the reverse proxy |
| Typical purposes | Egress control, filtering, caching for many users, anonymity | Load balancing, TLS termination, caching, routing, protection |
The "usually" entries matter. Knowledge is a deployment choice, not a property of the software. The same program, such as nginx, can be either one depending on how it is used.
What the request looks like on the wire
The difference shows up in the request itself.
With an explicit forward proxy, the client sends the proxy a request that names the full target, because the proxy cannot guess the destination from the connection. For plain HTTP, the request line carries an absolute URI:
GET http://example.org/index.html HTTP/1.1
Host: example.orgFor HTTPS, the client asks the proxy to open a tunnel with CONNECT:
CONNECT example.org:443 HTTP/1.1
Host: example.org:443
HTTP/1.1 200 Connection establishedAfter the 200, the proxy copies bytes in both directions and cannot read the encrypted traffic. The next chapter covers these mechanics in detail.
With a reverse proxy, the client sends an ordinary request to the public hostname. The request line has only a path, and the Host header says which site is wanted:
GET /index.html HTTP/1.1
Host: example.comThe client does not know a proxy handled it. The reverse proxy picks a backend and sends its own request onward. This is why a reverse proxy must pass the original Host along, or the backend may serve the wrong site.
Configuring each side
The configuration shows the same split. A reverse proxy lists backends the operator controls, and the destination is fixed by configuration:
upstream app_servers {
server 10.0.0.11:8080 max_fails=3 fail_timeout=30s;
server 10.0.0.12:8080 max_fails=3 fail_timeout=30s;
}
server {
listen 80;
server_name example.com;
location / {
proxy_pass http://app_servers;
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;
}
}Here the client chooses only the path and headers. The proxy chooses the destination from its own upstream list.
A forward proxy does the opposite. The client chooses the destination, and the proxy applies rules about which destinations are allowed:
http_port 3128
acl localnet src 10.0.0.0/8
acl allowed_sites dstdomain .example.org
http_access allow localnet allowed_sites
http_access deny allThe rules here are about who may connect (src) and where they may go (dstdomain). A client elsewhere is denied. A client in the allowed range asking for another site is also denied.
A client uses this proxy by naming it explicitly:
curl -x http://proxy.internal:3128 https://example.org/The client had to be told about proxy.internal:3128. The reverse proxy example needed no client-side setup at all.
Direction of trust and control
Who chose the proxy decides who can trust it and who is constrained by it.
- A forward proxy constrains clients. The organization that runs it can log, filter and block outgoing requests. A user who must use it has to trust its operator, because the operator sees which hosts are requested. With
CONNECT, the operator sees the destination host and port but not the content, unless the proxy performs TLS interception with a certificate the clients have been configured to trust. - A reverse proxy protects and shapes servers. The operator controls it, so the operator can terminate TLS, rewrite paths, limit rates and hide topology. Clients trust it implicitly, since its certificate is the one presented for the site's name.
This produces an asymmetry in who is the target of the destination decision. In a forward proxy, the client decides the destination and the proxy decides whether to allow it. In a reverse proxy, the proxy decides the destination and the client only decides what to ask for.
What the other side sees
Each proxy changes the apparent source of traffic, and each requires care.
For a forward proxy, the origin sees the proxy's address. Many clients share one address, so the origin may rate-limit them as one user. A forward proxy may add Via or X-Forwarded-For, but many are configured not to, in which case the origin cannot learn the real client.
For a reverse proxy, the backend sees the proxy's address on every connection. Anything that relies on the peer address, such as logging, rate limits by client, or geolocation, then sees the wrong value. The proxy fixes this by adding headers:
X-Forwarded-For: 203.0.113.7, 10.0.0.5
X-Forwarded-Proto: https
Forwarded: for=203.0.113.7;proto=https;host=example.comX-Forwarded-For is a list. Each proxy appends the address of the peer it received the request from. The leftmost value is the original client only if every proxy in the chain is trusted.
Failure and visibility differences
The two kinds also fail differently.
- If a forward proxy goes down, clients configured to use it lose outbound access, or fall back to a direct path if the network allows it. A fallback can silently bypass filtering policy.
- If a reverse proxy goes down, the whole site is unreachable, even if every backend is healthy. It is a single point of failure unless you run several behind a shared address or DNS entry.
- A reverse proxy hides backend failures when it can retry on another backend. A forward proxy cannot do this, because the destination is a third party's server and there is usually only one.
Debugging also differs. When a user reports an error, the question "which proxy handled this?" has a different answer. For a forward proxy, check the client's proxy settings and the proxy's access logs. For a reverse proxy, check the public DNS name, the proxy's upstream choice, and the backend's own logs.
Choosing between them
Use a forward proxy when you control a group of clients and want to control or observe their outbound traffic: restricting which sites staff can reach, caching downloads for many machines, or giving servers a single, known egress address that partners can allow-list.
Use a reverse proxy when you control a service and want a single entry point: spreading load, terminating TLS, caching responses, routing paths to different services, or keeping backend addresses private.
They are not alternatives. Many systems use both: backends reach external APIs through a forward proxy for egress control, while the public sees a reverse proxy in front of those same backends.
Common mistakes
- Treating software names as roles. nginx, HAProxy and Squid can be set up either way. The role comes from whose behalf the proxy acts on.
- Trusting
X-Forwarded-Forfrom the open internet, as described above. - Forgetting that the backend sees the proxy's address, then rate-limiting or banning by that address and blocking every user at once.
- Forgetting
Hosthandling in a reverse proxy, so the backend sees its own internal name instead ofexample.com. - Assuming a forward proxy can read HTTPS content. With
CONNECTit sees only the destination and the amount of data.
Exercise
A backend application logs the same IP address, 10.0.0.5, for every request, and per-client rate limiting blocks all users once one user is over the limit. Is the proxy in front of it a forward or reverse proxy, and what two changes fix the problem?
Show answer
It is a reverse proxy, because it was placed by the server operator in front of the backends and clients do not know about it. The backend sees the proxy's address as the peer. Fix it by having the proxy set X-Forwarded-For (or Forwarded) with the real client address, and by making the application read the client address from that header, trusting only entries added by proxies the operator controls.
Exercise
Your company wants to stop staff machines from reaching sites outside an approved list. Should you deploy a forward proxy or a reverse proxy, and why can the proxy still enforce a domain rule on an HTTPS request without decrypting it?
Show answer
Deploy a forward proxy, because the goal is to control what clients reach. For HTTPS, the client sends a CONNECT request naming the host and port, so the proxy can allow or deny it by destination domain before opening the tunnel, without reading the encrypted content.