Sub topic 7
Explicit and transparent proxy deployments
This chapter covers the two ways traffic reaches a forward proxy. In an explicit deployment the client is configured to use the proxy. In a transparent deployment the network redirects traffic to the proxy and the client never knows. The choice changes what the proxy can see, what it can enforce, and what breaks.
It assumes you know the forward proxy and CONNECT mechanics from earlier chapters, basic TCP/IP routing, and how TLS authenticates a server with a certificate.
Two meanings of "transparent"
The word "transparent" is used in two ways, and mixing them up causes confusion.
- Non-modifying. In the HTTP specifications, a transparent proxy forwards requests and responses without changing them beyond what is required. A proxy can be non-modifying and still be explicit.
- Interception. In everyday operations, a transparent proxy is one the client is unaware of. The network diverts the client's traffic to it. This is also called an intercepting proxy, and it is the meaning used in the rest of this chapter.
A proxy that is transparent in the interception sense usually modifies traffic anyway. It adds Via or X-Forwarded-For headers, caches, and filters.
Explicit deployment
In an explicit deployment, the client knows the proxy's address and sends its requests there on purpose. For plain HTTP, the client sends the request to the proxy using an absolute-form request target, such as GET http://example.org/ HTTP/1.1. The proxy reads the destination from that URL. For HTTPS, the client sends CONNECT example.org:443 first, as shown in the mechanics chapter.
The client is usually pointed at the proxy in one of four ways:
- Application settings. The browser or operating system has a proxy host and port entered by hand or by a management tool.
- Environment variables. Command-line tools such as
curland many language runtimes readhttp_proxy,https_proxyandno_proxy. - Command-line flags. For example
curl -x http://proxy.internal:3128 https://example.org/. - A proxy auto-config (PAC) file. A small script that the client downloads and runs for every URL. It decides, per URL, whether to use a proxy or connect directly.
A PAC file is JavaScript that defines FindProxyForURL:
function FindProxyForURL(url, host) {
// Internal names go straight to the server.
if (shExpMatch(host, "*.corp.example") || host === "localhost") {
return "DIRECT";
}
// Everything else uses the proxy, falling back to direct access
// if the proxy does not answer.
return "PROXY proxy.internal:3128; DIRECT";
}Note the ; DIRECT fallback. It keeps users online if the proxy is down. It also means that in an outage, your egress controls silently stop applying. Leave it out if the proxy is a security control rather than a convenience.
What explicit mode gives you
- Authentication. The proxy can answer
407 Proxy Authentication Required, and the client then sends credentials. You can filter by user, not only by IP address. - Clear errors. The client knows a proxy is involved, so a block page or a
502can be reported as a proxy problem. - Full protocol view. The proxy gets the destination host and port from the request line or the
CONNECTline. It does not have to guess. - Simple routing. Only traffic from configured clients reaches the proxy, so no network trickery is needed.
What explicit mode costs you
- Configuration drift. Every client must be configured, and every new device or container needs the setting.
- Bypass. A user or a piece of malware can ignore the setting and connect directly. Explicit proxying only enforces policy if the firewall also blocks direct outbound connections on those ports.
- Software that ignores proxies. Some applications do not read system settings. Some use protocols that are not HTTP.
The firewall rule is what makes an explicit proxy an enforcement point. A typical design allows the proxy host to reach the internet and denies outbound ports 80 and 443 from everything else. Clients then have no choice but to use the proxy.
Transparent (intercepting) deployment
In a transparent deployment, the client believes it is connecting straight to example.org. It resolves the name, opens a TCP connection to the real server's address on port 80 or 443, and sends an ordinary request. A device on the network path, usually the gateway or a router, catches that connection and hands it to the proxy.
Common interception mechanisms are:
- NAT redirect on the gateway. A firewall rule rewrites the destination of matching packets to the proxy's address and port. On Linux this is the
REDIRECTorDNATtarget. - TPROXY. A Linux mechanism that delivers packets to a local proxy socket without rewriting addresses, so the proxy can use the client's real source IP when contacting the server.
- Policy-based routing. The router sends traffic on selected ports to the proxy's next hop.
- WCCP. A protocol that lets a Cisco router and a cache cooperate in redirecting traffic.
A working Squid interception setup
The following runs on a Linux gateway that has Squid installed. The LAN interface is eth1, and the LAN is 10.0.0.0/8. Squid listens on port 3128 for explicit clients and on port 3129 for intercepted traffic.
http_port 3128
http_port 3129 intercept
acl localnet src 10.0.0.0/8
http_access allow localnet
http_access deny allThe gateway needs forwarding enabled and a redirect rule for web traffic that arrives from the LAN:
sudo sysctl -w net.ipv4.ip_forward=1
sudo iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 80 \
-j REDIRECT --to-ports 3129Squid's own outbound connections leave through the OUTPUT chain, not PREROUTING, so they are not redirected back to Squid. This avoids a forwarding loop. If the proxy runs on a separate machine from the redirecting router, you must exclude the proxy's own address from the redirect rule.
To test, run a request from a LAN client with no proxy configured, then read Squid's log on the gateway:
curl -v http://example.org/sudo tail -n 5 /var/log/squid/access.logIf the log shows the request, interception works.
The intercept keyword tells Squid to recover the original destination from the kernel's NAT table. Without it, Squid would see a request that is not addressed to it and would reject it.
What intercepting mode gives you
- Zero client configuration. Guest Wi-Fi, bring-your-own devices and appliances all get filtered or cached.
- No bypass through settings. A user cannot turn the proxy off in a menu.
- Easy rollout. You can add caching or logging to a network without touching any client.
What intercepting mode costs you
The network is lying to the client, and several things break because of that.
- HTTPS is opaque. The proxy sees only a TLS handshake. Without decrypting, it can read the SNI name in the ClientHello, when present, and the destination IP. It cannot see URLs, headers or bodies. Reading them requires TLS interception, which presents certificates signed by a private certificate authority that every client must trust. Certificate pinning, HSTS preload for some sites, and mutual TLS will fail through such a proxy.
- No proxy authentication. A browser that does not know about a proxy will not answer a
407. Squid does not support proxy authentication on intercepted ports. Identification falls back to source IP address. - Host and IP mismatch. The proxy learns the destination from the packet and the name from the
Hostheader. A client can send aHostvalue that does not match the IP. Squid checks this by default and rejects mismatches, because attackers can use the gap to poison a cache or evade filters. - Routing symmetry. Both directions of a connection must pass the intercepting device. Asymmetric paths produce stalled connections that are hard to diagnose.
- Confusing failures. A block page served over HTTPS, or a reset connection, looks like a broken website to the user, because the client does not know a proxy exists.
- Other protocols on port 80 or 443. Anything that is not HTTP or TLS on those ports breaks when it reaches a proxy that expects HTTP.
- Source address. Unless you use TPROXY, the origin server sees the proxy's address, not the client's.
Comparing the two
| Property | Explicit | Intercepting |
|---|---|---|
| Client configuration | Required on every client | None |
| Client awareness | Knows about the proxy | Unaware |
| Destination known from | Request line or `CONNECT` target | Kernel NAT table, `Host` header, SNI |
| Proxy authentication (`407`) | Supported | Not usable |
| HTTPS handling | `CONNECT` tunnel, content hidden unless intercepted | Content hidden unless TLS is intercepted with a trusted CA |
| Bypass by a user | Possible unless direct egress is blocked | Hard without network changes |
| Failure visibility | Client can report a proxy error | Looks like a server or network fault |
| Typical use | Corporate egress with user identity | Guest networks, ISPs, appliance fleets |
Where reverse proxies fit
Reverse proxies sit on the other side. The client already believes it is talking to the site, because DNS for example.com points at the proxy. No client setting and no interception is needed. That is why "explicit versus transparent" is a question about forward proxies. For a reverse proxy, the equivalent concern is only whether the backend gets the true client address, which is handled with X-Forwarded-For and Forwarded headers.
Choosing a deployment
- If you need per-user policy or logs, use explicit mode, and block direct egress so it cannot be skipped.
- If you cannot manage the clients, use interception, and accept the limits on HTTPS and identity.
- A mixed design is common. Run an explicit listener on 3128 for managed machines and an intercept listener for everything else, as in the Squid example above.
- Whatever you choose, monitor the proxy as a dependency. With interception, a failed proxy can look like a total network outage.
Exercise
A company runs Squid with an intercept port on its guest Wi-Fi gateway. Guests report that some banking apps fail while ordinary websites work, and the security team wants to filter by username. Give one reason for each problem and say what you would change.
Show answer
The banking apps probably use certificate pinning or mutual TLS, which fails if the proxy intercepts TLS with its own certificates. The fix is to not intercept TLS for those destinations and let the traffic pass as a tunnel or direct connection, filtering by SNI or IP only. Filtering by username is not possible on an intercepted port, because clients that do not know about the proxy cannot answer a 407 authentication challenge. To identify users, move managed devices to an explicit proxy (by PAC file or device settings) with authentication, and block direct outbound ports 80 and 443 for those devices.
Exercise
In the Squid and iptables example, why does Squid's own outbound traffic not loop back into port 3129?
Show answer
The redirect rule is in the nat table's PREROUTING chain, which only sees packets arriving from outside the host on the LAN interface. Squid's outbound connections are created locally and traverse the OUTPUT chain, so the rule never matches them.