---
title: "Forward proxy vs reverse proxy: tested side by side"
url: https://proxy.wiki/guides/forward-vs-reverse-proxy/
type: Guide
author: "proxy.wiki editorial"
published: 2026-10-21
updated: 2026-10-21
site: proxy.wiki
topics: ["Proxy fundamentals"]
license: CC BY 4.0; quote freely with attribution to https://proxy.wiki/
---

# Forward proxy vs reverse proxy: tested side by side

> A forward proxy acts for the client, a reverse proxy for the site. We ran Squid both ways and Apache as a reverse proxy, with the real headers and errors.

## Key takeaways

- A forward proxy is configured by the client and fetches any site it allows; a reverse proxy is reached through DNS and forwards only to its own backends.
- Through Squid 6.13 curl sent the full URL; through Apache 2.4.67 it sent an ordinary request and nothing in the response revealed the proxy.
- For HTTPS a forward proxy only tunnels: Squid logged 200 for a request the site answered with 404. A reverse proxy terminates TLS and sees everything.
- Pointing a client at a reverse proxy by mistake returned 200 with the wrong site's content, not an error.
- One Squid binary ran both roles. Forward or reverse describes how a proxy is deployed, not what was installed.

A forward proxy works for the client. The client is configured to send its requests there, and the proxy fetches whatever site the client names. A reverse proxy works for the site. Visitors reach it because DNS points the site’s hostname at it, they configure nothing, and it forwards only to the backend servers it was set up for. RFC 9110 draws the same line: a proxy is chosen by the client, while a gateway, which it also calls a reverse proxy, acts as the origin server toward whoever connects.

That is the definition. What follows is what it looks like on the wire. We ran Squid 6.13 as a forward proxy and Apache httpd 2.4.67 as a reverse proxy in front of the same small origin. The same request went through each. We recorded what the client sent, what the origin received, and what each proxy does when it is misused.

## Forward proxy vs reverse proxy at a glance

|  | Forward proxy | Reverse proxy |
| --- | --- | --- |
| Works for | The client | The site |
| Who sets it up | Whoever runs the clients: curl -x, HTTPS_PROXY, browser settings | Whoever runs the site: the hostname’s DNS record points at it |
| Does the client know it is there | Yes. It addresses the proxy and names the destination | No. It looks like the site |
| First line the client sends | GET http://host/path (full URL) | GET /path (path only) |
| Which sites it reaches | Any site its access rules allow | Only the backends in its own config |
| HTTPS | Builds a CONNECT tunnel; sees host and port, not the path | Terminates TLS; sees every header and the full URL |
| Certificate the client checks | The real site’s | The proxy’s own |
| Login challenge | 407 with Proxy-Authenticate | 401 with WWW-Authenticate |
| What the destination learns about the client | The proxy’s address, plus the client’s in X-Forwarded-For on a default Squid | The proxy’s address, plus the client’s in X-Forwarded-For, which the operator wants |
| Software we ran | Squid 6.13 | Apache httpd 2.4.67, and the same Squid 6.13 in accelerator mode |
| Typical jobs | Egress filtering, a shared cache for a group of users, sending traffic out from other addresses | TLS termination, load balancing, caching, rate limits and bot filtering |

If you only need the decision: you want a forward proxy when you control the clients and want their traffic to leave from somewhere else, and a reverse proxy when you control the servers and want one front door in front of them. The [forward proxy](/glossary/forward-proxy/) and [reverse proxy](/glossary/reverse-proxy/) glossary entries hold the short definitions; the rest of this page is the evidence.

## How we ran both

Everything ran on one Mac (Darwin 25.6.0) on 21 October 2026. curl was the client. Squid came from Homebrew. Apache is the build Apple ships in `/usr/sbin`. The origin is a 26-line Python server that prints its TCP peer, the request line and every header it received, in the order received.

```
$ squid -v | head -1
Squid Cache: Version 6.13
$ /usr/sbin/httpd -v | head -1
Server version: Apache/2.4.67 (Unix)
$ curl --version | head -1
curl 8.7.1 (x86_64-apple-darwin25.0) libcurl/8.7.1 (SecureTransport) LibreSSL/3.3.6 zlib/1.2.12 nghttp2/1.68.1
$ python3 --version
Python 3.15.0
```

One detail makes the captures easy to read. The client reaches each proxy over IPv6 loopback, `::1`, and each proxy reaches the origin over IPv4 loopback, `127.0.0.1`. So when the origin reports `::1`, the value came from a header. When it reports `127.0.0.1`, that was the proxy’s own connection.

The origin:

```
#!/usr/bin/env python3
"""Echo origin: prints exactly what reached it, peer address first."""
import sys
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer

class Echo(BaseHTTPRequestHandler):
    protocol_version = "HTTP/1.1"

    def _echo(self):
        out = [f"tcp-peer: {self.client_address[0]}", f"request-line: {self.requestline}"]
        out += [f"{k}: {v}" for k, v in self.headers.items()]
        body = ("\n".join(out) + "\n").encode()
        self.send_response(200)
        self.send_header("Content-Type", "text/plain")
        self.send_header("Content-Length", str(len(body)))
        self.end_headers()
        if self.command != "HEAD":
            self.wfile.write(body)

    do_GET = do_POST = do_HEAD = _echo

    def log_message(self, *args):
        pass

port = int(sys.argv[1]) if len(sys.argv) > 1 else 29000
ThreadingHTTPServer(("127.0.0.1", port), Echo).serve_forever()
```

The forward proxy. Nothing here is unusual; it allows loopback clients and caches nothing so every request reaches the origin.

```
# squid-forward.conf: Squid 6.13 as a forward proxy
http_port [::1]:23128
visible_hostname fwd.lab.example
acl lab src ::1 127.0.0.1
http_access allow lab
http_access deny all
cache deny all
pid_filename /tmp/lab/run/squid-forward.pid
access_log stdio:/tmp/lab/logs/squid-forward-access.log
cache_log /tmp/lab/logs/squid-forward-cache.log
coredump_dir /tmp/lab/run
```

The reverse proxy. `ProxyRequests Off` is the default and is stated only for clarity. `ProxyPass` is the line that makes Apache a reverse proxy.

```
# apache-reverse.conf: Apache 2.4.67 as a reverse proxy
ServerRoot "/usr"
DefaultRuntimeDir "/tmp/lab/run"
PidFile "/tmp/lab/run/apache-reverse.pid"
Listen [::1]:23080
LoadModule mpm_event_module libexec/apache2/mod_mpm_event.so
LoadModule unixd_module libexec/apache2/mod_unixd.so
LoadModule authz_core_module libexec/apache2/mod_authz_core.so
LoadModule log_config_module libexec/apache2/mod_log_config.so
LoadModule proxy_module libexec/apache2/mod_proxy.so
LoadModule proxy_http_module libexec/apache2/mod_proxy_http.so
ServerName rev.lab.example
ErrorLog "/tmp/lab/logs/apache-reverse-error.log"
LogFormat "%a %r %>s" brief
CustomLog "/tmp/lab/logs/apache-reverse-access.log" brief
ProxyRequests Off
ProxyPass        "/" "http://127.0.0.1:29000/"
ProxyPassReverse "/" "http://127.0.0.1:29000/"
```

Each capture below is a single request, trimmed to the relevant lines. Lines starting with `#` are our labels, timestamps and process IDs are cut from error-log lines, and the lab password is redacted. Nothing else is edited. These are default behaviours of the software, not timings, so one request per case is the honest sample size. We ran the lab from a different directory; the configs here use `/tmp/lab`, so create it or change the path.

## The same request through each

### Through the forward proxy

What curl sent and received:

```
$ curl -v -x 'http://[::1]:23128' http://127.0.0.1:29000/hello
* Connected to ::1 (::1) port 23128
> GET http://127.0.0.1:29000/hello HTTP/1.1
> Host: 127.0.0.1:29000
> User-Agent: curl/8.7.1
> Accept: */*
> Proxy-Connection: Keep-Alive
>
< HTTP/1.1 200 OK
< Server: BaseHTTP Python/3.15.0
< Content-Type: text/plain
< Content-Length: 223
< Cache-Status: fwd.lab.example;detail=no-cache
< Via: 1.1 fwd.lab.example (squid/6.13)
< Connection: keep-alive
```

What reached the origin:

```
tcp-peer: 127.0.0.1
request-line: GET /hello HTTP/1.1
Host: 127.0.0.1:29000
User-Agent: curl/8.7.1
Accept: */*
Via: 1.1 fwd.lab.example (squid/6.13)
X-Forwarded-For: ::1
Cache-Control: max-age=259200
Connection: keep-alive
```

### Through the reverse proxy

What curl sent and received:

```
$ curl -v 'http://[::1]:23080/hello'
* Connected to ::1 (::1) port 23080
> GET /hello HTTP/1.1
> Host: [::1]:23080
> User-Agent: curl/8.7.1
> Accept: */*
>
< HTTP/1.1 200 OK
< Server: BaseHTTP Python/3.15.0
< Content-Type: text/plain
< Content-Length: 221
```

What reached the origin:

```
tcp-peer: 127.0.0.1
request-line: GET /hello HTTP/1.1
Host: 127.0.0.1:29000
User-Agent: curl/8.7.1
Accept: */*
X-Forwarded-For: ::1
X-Forwarded-Host: [::1]:23080
X-Forwarded-Server: rev.lab.example
Connection: Keep-Alive
```

We also sent the request through Squid configured as a reverse proxy, which the section on running one binary both ways covers. Side by side, this is what the origin received in each case:

| At the origin | Direct, no proxy | Squid forward | Apache reverse | Squid reverse |
| --- | --- | --- | --- | --- |
| TCP peer | 127.0.0.1 (curl) | 127.0.0.1 (Squid) | 127.0.0.1 (Apache) | 127.0.0.1 (Squid) |
| Request line | GET /hello | GET /hello | GET /hello | GET /hello |
| Host | 127.0.0.1:29000 | 127.0.0.1:29000 | 127.0.0.1:29000, rewritten from [::1]:23080 | app.lab.example, rewritten from [::1]:23180 |
| Via | — | 1.1 fwd.lab.example (squid/6.13) | — | 1.1 rev.lab.example (squid/6.13) |
| X-Forwarded-For | — | ::1 | ::1 | ::1 |
| X-Forwarded-Host | — | — | [::1]:23080 | — |
| X-Forwarded-Server | — | — | rev.lab.example | — |
| Cache-Control | — | max-age=259200 | — | max-age=259200 |
| Surrogate-Capability | — | — | — | rev.lab.example=”Surrogate/1.0″ |
| Via on the response to curl | — | Yes | — | Yes |

A dash means the header was absent. Squid added `Cache-Control: max-age=259200`, three days in seconds, in both roles. We did not configure it. With no `refresh_pattern` lines, as in our configs, that is Squid’s built-in `REFRESH_DEFAULT_MAX` from `src/RefreshPattern.h`, and `src/http.cc` adds it to any forwarded request that carries no `max-age` or `no-cache` of its own. Both proxies more than doubled the header bytes of a minimal curl request:

_Request line plus headers received by the origin, counted with CRLF line endings. One curl 8.7.1 request per row, 21 October 2026._

| Path to the origin | Bytes received |
| --- | --- |
| Direct, no proxy | 83 |
| Squid 6.13 forward | 199 |
| Apache 2.4.67 reverse | 197 |
| Apache 2.4.67 reverse, TLS terminated | 239 |
| Squid 6.13 reverse | 254 |

Some of the spread is lab detail. The TLS row includes an `X-Forwarded-Proto` header we set ourselves, 26 of its bytes, plus longer hostnames. The headers each proxy adds unasked are what matters. Our [default request headers research](/research/default-request-headers/) covers what clients send before any proxy adds to it.

## The differences that bite in practice

### The client addresses a forward proxy and never sees a reverse one

The first line curl sent to Squid carried the whole URL, `GET http://127.0.0.1:29000/hello`. RFC 9112 section 3.2.2 requires that absolute form for any request to a proxy except CONNECT and server-wide OPTIONS. curl also added `Proxy-Connection: Keep-Alive`, which it did not send on the direct request. Squid then turned the request back into the ordinary path-only form before passing it on.

Against Apache, curl sent an ordinary request to what it took for the site. Nothing in the response gave the proxy away. The `Server` header belonged to the Python origin and there was no `Via`. With Apache’s defaults the reverse proxy was invisible from the client’s side. Squid in accelerator mode did add `Via` to its responses, so whether a reverse proxy shows up in response headers depends on the software and on what its operator leaves switched on.

The operational consequence is about where configuration lives. A forward proxy has to be set in every client: each tool reads its own flag or [environment variable](/guides/proxy-environment-variables/), and the [curl proxy guide](/guides/how-to-use-a-proxy-with-curl/) lists the forms curl accepts. A reverse proxy needs no client change at all. You move a DNS record and every visitor goes through it.

### The backend sees a different Host than the visitor typed

Apache sent `Host: 127.0.0.1:29000`, the address in its `ProxyPass` line, not the `[::1]:23080` that curl asked for. That is documented behaviour: `ProxyPreserveHost` defaults to Off. nginx documents the same default, `proxy_set_header Host $proxy_host`; we did not run nginx for this page. Squid in reverse mode replaced the Host with its `defaultsite` value.

This breaks real applications. A backend that builds redirects or absolute links from the Host header will hand visitors its internal address. A backend that routes by virtual host picks the wrong site. Apache’s `ProxyPassReverse` repairs the `Location`, `Content-Location` and `URI` headers on redirects, and its documentation is explicit that it rewrites nothing else, so links inside a page stay broken. Setting `ProxyPreserveHost On` fixes it at the source. We set it for the TLS run below, and the backend received the hostname the visitor used.

A forward proxy has no such problem, because the client named the destination itself and the Host header stays as sent.

### HTTPS: a tunnel on one side, a termination on the other

Through the forward proxy, an HTTPS request starts with CONNECT. Once Squid answers 200, it relays bytes and nothing else. RFC 9110 section 9.3.6 calls this blind forwarding. The certificate curl verified was the real site’s:

```
$ curl -v -o /dev/null -x 'http://[::1]:23128' https://example.com/
> CONNECT example.com:443 HTTP/1.1
> Host: example.com:443
> User-Agent: curl/8.7.1
> Proxy-Connection: Keep-Alive
>
< HTTP/1.1 200 Connection established
<
* CONNECT tunnel established, response 200
* Server certificate:
*  subject: CN=example.com
*  issuer: C=US; O=SSL Corporation; CN=Cloudflare TLS Issuing ECC CA 3
*  SSL certificate verify ok.
> GET / HTTP/2
> Host: example.com
< HTTP/2 200
< server: cloudflare
< cf-cache-status: HIT
```

The reverse proxy is the opposite. We gave Apache a self-signed certificate for `app.lab.example` and the curl session checked that certificate, not anything belonging to the origin. The origin received plain HTTP. `X-Forwarded-Proto` is there only because we added it with `RequestHeader set`; Apache’s automatic headers are the three `X-Forwarded-For`, `-Host` and `-Server`.

```
$ curl -v --cacert app.crt --resolve 'app.lab.example:23443:::1' https://app.lab.example:23443/hello
* Server certificate:
*  subject: CN=app.lab.example
*  issuer: CN=app.lab.example
*  SSL certificate verify ok.
> GET /hello HTTP/1.1
> Host: app.lab.example:23443

# what the origin received, over plain HTTP
tcp-peer: 127.0.0.1
request-line: GET /hello HTTP/1.1
Host: app.lab.example:23443
X-Forwarded-Proto: https
X-Forwarded-For: ::1
X-Forwarded-Host: app.lab.example:23443
X-Forwarded-Server: app.lab.example
```

The two proxies’ logs for the same path, `/account/orders?page=2`, show what each one can know:

```
# Apache reverse proxy, TLS terminated, request for /account/orders?page=2
::1 "GET /account/orders?page=2 HTTP/1.1" 200

# Squid forward proxy, same path requested on https://example.com
1792611232.074     56 ::1 TCP_TUNNEL/200 4901 CONNECT example.com:443 - HIER_DIRECT/172.66.147.243 -
```

The reverse proxy logged the path, the query string and the real status. The forward proxy logged a host, a port, a byte count and a 200. example.com actually answered that request with 404 inside the tunnel. The 200 in Squid’s log is the status of the tunnel, not of the page. Anyone diagnosing failures from a forward proxy’s log needs to know that, and the [HTTP CONNECT](/glossary/http-connect/) entry explains the method. The exception is a forward proxy doing [TLS interception](/glossary/tls-interception/), which decrypts by issuing its own certificates to clients that trust its CA.

### Logins: 407 from one, 401 from the other

We started a second Squid that requires a login and a second Apache that does the same, both with a throwaway lab account:

```
$ curl -i -x 'http://[::1]:23129' http://127.0.0.1:29000/hello
HTTP/1.1 407 Proxy Authentication Required
Server: squid/6.13
X-Squid-Error: ERR_CACHE_ACCESS_DENIED 0
Proxy-Authenticate: Basic realm="lab-forward-proxy"
Via: 1.1 fwd.lab.example (squid/6.13)

$ curl -i 'http://[::1]:23081/hello'
HTTP/1.1 401 Unauthorized
Server: Apache/2.4.67 (Unix)
WWW-Authenticate: Basic realm="lab-reverse-proxy"
```

The forward proxy asks with 407 and `Proxy-Authenticate`. The reverse proxy asks with 401 and `WWW-Authenticate`, exactly like a web server, because to the client it is the web server. curl takes the first with `-U` or `--proxy-user` and the second with `-u`. Mixing them up just produces the same challenge again. The [403 vs 407 vs 429 guide](/guides/403-vs-407-vs-429/) covers reading those codes when a proxied request fails.

The bigger difference is where the credentials go once accepted:

```
# origin view, forward proxy, curl -U labuser:... (proxy login)
Via: 1.1 fwd.lab.example (squid/6.13)
X-Forwarded-For: ::1
# no Proxy-Authorization header arrived

# origin view, reverse proxy, curl -u labuser:... (site login)
Authorization: Basic <base64 of labuser:password>
X-Forwarded-For: ::1
X-Forwarded-Host: [::1]:23081
```

Squid consumed the proxy login and the origin never saw it. RFC 9110 section 11.7.2 says the first proxy expecting credentials consumes them. Apache passed the visitor’s `Authorization` header straight through to the backend. That is expected for a reverse proxy, because the backend usually wants it, and it means the backend and everything behind the proxy can read those credentials. The [proxy authentication](/glossary/proxy-authentication/) entry covers the schemes.

### Via: Squid adds it, Apache’s default does not

Squid added `Via` to requests and responses in both roles. Apache added none, because `ProxyVia` defaults to Off. RFC 9110 section 7.6.3 says an HTTP-to-HTTP gateway must send `Via` on each request it forwards inbound, so Apache’s default is quieter than the standard asks. Squid’s `via off` removes the header too. The practical reading, also in our [Via header](/glossary/via-header/) entry: a missing `Via` proves nothing about whether a proxy is present.

### X-Forwarded-For is only as honest as the hop that wrote it

We sent a forged header from the client:

```
$ curl -H 'X-Forwarded-For: 203.0.113.9' -x 'http://[::1]:23128' http://127.0.0.1:29000/xff
X-Forwarded-For: 203.0.113.9, ::1

$ curl -H 'X-Forwarded-For: 203.0.113.9' 'http://[::1]:23080/xff'
X-Forwarded-For: 203.0.113.9, ::1
```

Both proxies appended the real client address and kept the forged one. Squid in reverse mode did the same. So a backend can trust only the entries added by proxies it runs itself, read from the right. Behind your own reverse proxy, the rightmost entry is the one your proxy wrote and the rest are claims. Through someone else’s forward proxy, the whole header is the sender’s claim. Squid’s `forwarded_for` directive takes `delete` to drop the header or `truncate` to replace it with the client address alone. None of the three sent the standard `Forwarded` header from RFC 7239 by default. See [X-Forwarded-For](/glossary/x-forwarded-for/) for parsing rules.

## Using one where the other belongs

These are the mistakes people make when a port number is wrong or a tool has been pointed at the wrong thing. Each row is one request against our lab, with the exact strings returned.

| What we did | Status | Exact signature |
| --- | --- | --- |
| Sent a plain request to the forward proxy as if it were the site: curl 'http://[::1]:23128/hello' | 400 Bad Request | X-Squid-Error: ERR_INVALID_URL 0 |
| Used the Apache reverse proxy as a forward proxy for another site: curl -x 'http://[::1]:23080' http://example.org/ | 200 OK | The lab backend’s content; the backend saw X-Forwarded-Host: example.org |
| Used the Squid reverse proxy the same way | 200 OK | The lab backend’s content with Host: app.lab.example |
| Sent CONNECT to the Apache reverse proxy: curl -p -x 'http://[::1]:23080' https://example.com/ | 501 | 501 Unsupported method ('CONNECT') from Server: BaseHTTP Python/3.15.0; curl printed curl: (56) CONNECT tunnel failed, response 501 |
| Sent CONNECT to the Squid reverse proxy | 405 Method Not Allowed | X-Squid-Error: ERR_UNSUP_REQ 0; curl printed curl: (56) CONNECT tunnel failed, response 405 |

The second and third rows are the ones that waste an afternoon. Pointing a client at a reverse proxy by mistake did not produce an error. It produced a 200 and plausible content from the wrong site. A reverse proxy with `ProxyRequests Off` does not fetch arbitrary URLs; it maps the path onto its own backend and ignores the host you named. That is correct and safe, and completely silent. Check the content, not only the status code.

The fourth row is a different trap. Apache did not reject CONNECT itself. It forwarded the method to the backend, and the 501 came from the Python application. An error from behind a reverse proxy can belong to any layer, and the `Server` header is the quickest way to tell which.

## When the origin is down

We stopped the origin and repeated the request through each proxy:

```
# Squid forward proxy, origin stopped
HTTP/1.1 503 Service Unavailable
Server: squid/6.13
X-Squid-Error: ERR_CONNECT_FAIL 61

# Apache reverse proxy, origin stopped
HTTP/1.1 503 Service Unavailable
Server: Apache/2.4.67 (Unix)

# Apache error log
[proxy:error] (61)Connection refused: AH00957: http: attempt to connect to 127.0.0.1:29000 (127.0.0.1:29000) failed
[proxy_http:error] [client ::1:57882] AH01114: HTTP: failed to make connection to backend: 127.0.0.1
```

Both returned 503, from different owners. Through a forward proxy, a 503 is about a site you do not run: retry later or move on. Through your own reverse proxy, it means your backend is down and somebody should be paged. Squid in reverse mode printed the same `ERR_CONNECT_FAIL 61` and logged `ERROR: Connection to origin failed`. The 61 is the operating system’s errno for a refused connection on macOS. On Linux the same constant is 111, which we confirmed with Python on a Linux 6.8 server, so a Linux Squid should print `ERR_CONNECT_FAIL 111` for this failure.

## Same software, both directions

The Squid binary that ran the forward proxy also ran a reverse proxy. The only meaningful changes were two lines, the `accel` flag on `http_port` and a `cache_peer` marked `originserver`, the pattern Squid’s own wiki gives for a basic accelerator. The `cache_peer_access` line only restates Squid’s default, which places no restrictions on peer use.

```
# squid-reverse.conf: the same Squid 6.13 binary as a reverse proxy
http_port [::1]:23180 accel defaultsite=app.lab.example no-vhost
cache_peer 127.0.0.1 parent 29000 0 no-query originserver name=origin
visible_hostname rev.lab.example
acl lab src ::1 127.0.0.1
http_access allow lab
http_access deny all
cache_peer_access origin allow all
cache deny all
pid_filename /tmp/lab/run/squid-reverse.pid
access_log stdio:/tmp/lab/logs/squid-reverse-access.log
cache_log /tmp/lab/logs/squid-reverse-cache.log
coredump_dir /tmp/lab/run
```

Apache works the same way in the other direction. Its documentation describes `ProxyRequests On` as what lets it act as a forward proxy, with mod_proxy_connect needed for HTTPS, and warns in plain words: “Open proxy servers are dangerous both to your network and to the Internet at large.” So “is this product a forward or a reverse proxy?” is the wrong question. Forward and reverse describe how a proxy is deployed and whom it serves, not what was installed.

If you turn on forward proxying to test something, restrict who may use it before the port is reachable from anywhere. The Squid configs on this page bind to `::1` and allow only loopback clients for that reason.

## One request, both kinds of proxy

The CONNECT capture above passed through both kinds at once. Squid was the forward proxy, on our side. The other end was a reverse proxy belonging to example.com’s operator. `dig` returned `104.20.23.154` and `172.66.147.243`; Team Cymru’s whois service mapped the second to AS13335, CLOUDFLARENET; the response carried `server: cloudflare` and `cf-cache-status: HIT`; and the certificate came from a Cloudflare issuing CA. The page was served from Cloudflare’s cache, so the origin may never have seen the request at all.

That is the normal layout for anyone collecting data. The proxy you pay for or run is a forward proxy, and it decides which address the target sees. The target’s edge is a reverse proxy, and it decides whether you get the page. Blocks, challenges and rate limits are often issued at that edge by an [anti-bot system](/glossary/anti-bot-system/), which is why changing your exit address helps with some blocks and not others. The [guide to proxy servers](/guides/what-is-a-proxy-server/) and the [proxy types comparison](/guides/residential-vs-datacenter-proxies/) cover the forward side in more depth.

## When each one is the right choice

Use a forward proxy when you control the clients:

- Their traffic should leave from a different address, country or pool of addresses.

- You need to filter or log what a group of machines can reach.

- Many clients fetch the same outside content and one shared cache saves the transfer. Package managers are the classic case, covered in [proxies for git, npm and pip](/guides/proxies-for-git-npm-pip/).

Use a reverse proxy when you control the servers:

- You want TLS certificates managed in one place instead of on every backend.

- Several backends sit behind one hostname and need load balancing or routing by path.

- You want caching, compression, rate limits or bot filtering applied before a request costs the application anything.

- You would rather not expose backend addresses to the internet.

And the cases where the wrong one cannot help. A reverse proxy will not hide your address from sites you visit; it belongs to someone else’s site. A forward proxy will not protect your server; your visitors never pass through it. If a network pushes traffic through a proxy without any client setting, that is a [transparent proxy](/glossary/transparent-proxy/), a forward proxy the client did not choose.

## Reproduce it

With the four files above saved in `/tmp/lab`, this starts the lab, sends the main requests and stops it again. Squid needs to be installed; Apache is already on macOS. On Linux the Apache module paths differ by distribution.

```
mkdir -p /tmp/lab/run /tmp/lab/logs && cd /tmp/lab
# save origin.py, squid-forward.conf, squid-reverse.conf and apache-reverse.conf here first

python3 origin.py 29000 &
squid -N -f squid-forward.conf &
squid -N -f squid-reverse.conf &
/usr/sbin/httpd -f /tmp/lab/apache-reverse.conf -k start
sleep 2   # give both Squids a moment to open their ports

curl -v -x 'http://[::1]:23128' http://127.0.0.1:29000/hello   # forward
curl -v 'http://[::1]:23080/hello'                              # reverse, Apache
curl -v 'http://[::1]:23180/hello'                              # reverse, Squid
curl -v -o /dev/null -x 'http://[::1]:23128' https://example.com/   # CONNECT

# stop everything; each Squid closes its port at once and exits after
# shutdown_lifetime, 30 seconds by default
/usr/sbin/httpd -f /tmp/lab/apache-reverse.conf -k stop
squid -k shutdown -f squid-forward.conf
squid -k shutdown -f squid-reverse.conf
kill %1
```

## Frequently asked questions

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

A forward proxy acts for clients. They are configured to send requests to it, and it fetches whatever site they name. A reverse proxy acts for a site. DNS sends visitors to it, they configure nothing, and it forwards requests only to the backend servers it was set up for.

### Is Cloudflare a forward proxy or a reverse proxy?

For a site that uses it as a CDN, it is a reverse proxy. Our request to example.com reached an address in AS13335 (Cloudflare), was answered with server: cloudflare and cf-cache-status: HIT, and presented a certificate from a Cloudflare issuing CA. The site's operator chose it, not the visitor. Cloudflare also runs Gateway, which companies send their own users' outbound traffic through for filtering and logging. In that role it is a forward proxy.

### Can the same software be both a forward and a reverse proxy?

Yes. We ran one Squid 6.13 binary in both roles with two config files. The reverse one differed by the accel flag on http_port and a cache_peer marked originserver. Apache does the same: ProxyRequests On makes it a forward proxy, and ProxyPass makes it a reverse proxy.

### Does a reverse proxy hide my IP address when I browse or scrape?

No. A reverse proxy sits in front of a site and belongs to that site's operator. To change the address a site sees, you need a forward proxy, or a VPN, on your side of the connection.

### Why does my forward proxy log show 200 for HTTPS requests that failed?

For HTTPS the client sends CONNECT and the proxy only builds a tunnel. The 200 it logs is the tunnel being established. The real response travels encrypted inside it. In our test Squid logged TCP_TUNNEL/200 while example.com answered the request inside the tunnel with 404.

### Which status code means a proxy wants a login?

407 Proxy Authentication Required, with a Proxy-Authenticate header, comes from a forward proxy. A reverse proxy that requires a login answers 401 with WWW-Authenticate, exactly as a web server does, because to the client it is the web server.

## Sources

1. [RFC 9110 section 3.7: Intermediaries (proxy and gateway defined)](https://www.rfc-editor.org/rfc/rfc9110.html#section-3.7)
2. [RFC 9110 section 9.3.6: CONNECT](https://www.rfc-editor.org/rfc/rfc9110.html#section-9.3.6)
3. [RFC 9110 section 11.7.2: Proxy-Authorization](https://www.rfc-editor.org/rfc/rfc9110.html#section-11.7.2)
4. [RFC 9110 section 7.6.3: Via](https://www.rfc-editor.org/rfc/rfc9110.html#section-7.6.3)
5. [RFC 9112 section 3.2.2: absolute-form request target](https://www.rfc-editor.org/rfc/rfc9112.html#section-3.2.2)
6. [RFC 7239: Forwarded HTTP Extension](https://www.rfc-editor.org/rfc/rfc7239.html)
7. [Apache HTTP Server 2.4 documentation: mod_proxy (ProxyRequests, ProxyPreserveHost, ProxyVia, ProxyAddHeaders, ProxyPassReverse)](https://httpd.apache.org/docs/2.4/mod/mod_proxy.html)
8. [Squid configuration reference: http_port (accel mode)](https://www.squid-cache.org/Doc/config/http_port/)
9. [Squid configuration reference: forwarded_for](https://www.squid-cache.org/Doc/config/forwarded_for/)
10. [Squid configuration reference: via](https://www.squid-cache.org/Doc/config/via/)
11. [Squid wiki: basic reverse proxy (accelerator) configuration](https://wiki.squid-cache.org/ConfigExamples/Reverse/BasicAccelerator)
12. [nginx documentation: ngx_http_proxy_module (proxy_set_header defaults)](https://nginx.org/en/docs/http/ngx_http_proxy_module.html)
13. [Team Cymru IP to ASN mapping service (whois.cymru.com)](https://www.team-cymru.com/ip-asn-mapping)
14. [Squid configuration reference: shutdown_lifetime (default 30 seconds)](https://www.squid-cache.org/Doc/config/shutdown_lifetime/)
15. [Squid configuration reference: cache_peer_access (default: no peer usage restrictions)](https://www.squid-cache.org/Doc/config/cache_peer_access/)
16. [Squid 6.13 source: src/RefreshPattern.h, REFRESH_DEFAULT_MAX = 259200](https://github.com/squid-cache/squid/blob/SQUID_6_13/src/RefreshPattern.h)
17. [Squid 6.13 source: src/http.cc, adds Cache-Control max-age to forwarded requests](https://github.com/squid-cache/squid/blob/SQUID_6_13/src/http.cc)
18. [Cloudflare One documentation: Gateway proxy](https://developers.cloudflare.com/cloudflare-one/traffic-controls/proxy/)
