A forward proxy is the box that internal hosts send outbound web traffic through — for filtering, auditing, caching, or simply because no internal host should reach the public internet directly. Squid is the canonical implementation, and despite being older than most software in your stack, it is still the right tool for the job in 2026. This article is the install and the first useful policy: bind, listen, write ACLs that allow what the business needs and log what it sees.
How to verify
Before installing, confirm what currently allows outbound traffic from the host and how clients will be routed.
ss -ltnp | grep -E ':(3128|8080)\b'
curl -sS --proxy http://proxy.internal:3128 https://example.com -o /dev/null -w '%{http_code}\n'
dpkg -l | grep squid
ip route get 1.1.1.1
If the response code is 200 already, a proxy is in place — figure out which one before you put a second in front. If it is 000, network egress is blocked or routed elsewhere; resolve that before touching Squid.
What’s happening
A forward proxy sits between clients and external destinations. Clients are configured to send HTTP requests to the proxy (via HTTP_PROXY env var, browser settings, or transparent interception) and the proxy forwards on their behalf. For plain HTTP this is straightforward — the proxy sees the URL, the method, the headers, and can rewrite or cache.
For HTTPS, the client issues a CONNECT host:443 HTTP/1.1 to the proxy; the proxy opens a TCP tunnel to the destination and the client speaks TLS through it. The proxy sees the destination hostname (from the CONNECT line and from SNI) but not the request URL or body. If you want to inspect HTTPS content you have to do TLS interception (“SSL bump”) — the proxy presents its own cert (signed by a root your clients trust) and talks TLS to the destination. That is a policy decision with privacy, legal, and trust-store implications; it is not a default we recommend.
Squid is configuration-heavy. The default squid.conf is several thousand lines including comments — the policy you write is small, but it matters where in the file the ACL lives because Squid evaluates them in order.
The procedure
-
Install Squid and lay down a minimal config. Strip the default
squid.confto a working skeleton; the shipped file is reference material, not a starting point.apt update && apt install -y squid mv /etc/squid/squid.conf /etc/squid/squid.conf.dist cat > /etc/squid/squid.conf <<'EOF' http_port 3128 visible_hostname proxy.internal coredump_dir /var/spool/squid acl internal_nets src 10.0.0.0/8 172.16.0.0/12 192.168.0.0/16 acl SSL_ports port 443 acl Safe_ports port 80 21 443 70 210 1025-65535 280 488 591 777 acl CONNECT method CONNECT http_access deny !Safe_ports http_access deny CONNECT !SSL_ports http_access allow internal_nets http_access deny all access_log daemon:/var/log/squid/access.log squid cache_log /var/log/squid/cache.log cache deny all EOF systemctl enable --now squid -
Add destination allow-lists. Most engagements need outbound limited to specific domains; build the list explicitly rather than allowing all of
internal_nets.cat > /etc/squid/allowed_destinations.txt <<'EOF' .ubuntu.com .debian.org .docker.io .githubusercontent.com .pypi.org EOF # add to squid.conf acl allowed_dests dstdomain "/etc/squid/allowed_destinations.txt" http_access allow internal_nets allowed_dests http_access deny internal_nets -
Add basic-auth for non-IP authentication. Useful when traffic comes from a shared subnet where IP is not enough.
apt install -y apache2-utils htpasswd -c -B /etc/squid/passwords alice # add to squid.conf above the internal_nets allow: auth_param basic program /usr/lib/squid/basic_ncsa_auth /etc/squid/passwords auth_param basic realm "Forward Proxy" acl authenticated proxy_auth REQUIRED http_access allow authenticated allowed_dests -
Reload and test. Squid supports
-k reconfigurefor hot reload — no dropped connections.squid -k parse # syntax-check squid -k reconfigure # hot reload curl -sS --proxy http://proxy:3128 https://github.com -o /dev/null -w '%{http_code}\n' curl -sS --proxy http://proxy:3128 https://evil.example.com -o /dev/null -w '%{http_code}\n' tail -f /var/log/squid/access.log -
Ship the access log to your central pipeline. A forward proxy without log shipping is a black box; we route the access log to Loki/Elastic with hostname enrichment.
# /etc/vector/vector.toml [sources.squid] type = "file" include = ["/var/log/squid/access.log"] [transforms.parse] type = "remap" inputs = ["squid"] source = '. = parse_regex!(.message, r"^(?P<ts>\S+)\s+(?P<elapsed>\d+)\s+(?P<client>\S+)\s+(?P<status>\S+)\s+(?P<size>\d+)\s+(?P<method>\S+)\s+(?P<url>\S+)")' [sinks.loki] type = "loki" inputs = ["parse"] endpoint = "http://loki:3100"
Common pitfalls
- Allowing
localhostorlocalnetfrom the default config without scoping — that lets anything from your subnet proxy through with no auth. - Not declaring
Safe_portsand getting surprised when clients fail on unusual ports (e.g. internal port 5000) — the default list is restrictive. - Letting the access log grow on the box; rotate via
logrotateand ship offsite. A full disk takes the proxy down. - Doing TLS interception without communicating it to users — that is a privacy and policy posture, not a config flag.
- Caching outbound responses (
cache allow all) on a proxy that fronts privileged downloads — package signatures and tokens end up in the cache.
In the engagements we run, the forward proxy is rarely “Squid by itself” — it sits next to a transparent firewall, a DNS resolver, and a SIEM ingestion pipeline. Stack Harbor builds the proxy as part of the egress posture for clustered environments — every outbound HTTP request is auditable, scoped, and rate-limited at the boundary.