Configuring Squid as a Forward or Transparent Proxy with SSL Interception
This guide explains how to set up Squid as an explicit or implicit forward proxy on Linux, covering SSL/TLS termination, required build tools, user creation, compilation options, CA generation, detailed squid.conf settings, and necessary iptables NAT rules.
Squid is a popular forwarding proxy that can intercept both plain HTTP and SSL/TLS traffic; it can operate in explicit mode where clients are aware of the proxy, or in implicit (transparent) mode where traffic is redirected without client configuration, each with distinct security implications.
Implicit proxies can terminate SSL connections, decrypt traffic, re‑encrypt it, and even modify the encryption protocol on the fly, which is useful for legacy applications that only support older TLS versions.
To get started, download the latest stable Squid (e.g., 3.5), extract it, and ensure your Linux distribution has the necessary build tools such as gcc , make , and the build-essential package (on Ubuntu). Create a dedicated system user for Squid:
adduser squid
Configure the build with the required options:
./configure --prefix=/usr --exec-prefix=/usr --includedir=/usr/include --datadir=/usr/share --libdir=/usr/lib64 --libexecdir=/usr/lib64/squid --localstatedir=/var --sysconfdir=/etc/squid --sharedstatedir=/var/lib --with-logdir=/var/log/squid --with-pidfile=/var/run/squid.pid --with-default-user=squid --enable-silent-rules --enable-dependency-tracking --with-openssl --enable-icmp --enable-delay-pools --enable-useragent-log --enable-esi --enable-follow-x-forwarded-for --enable-auth --enable-ssl-crtd --disable-arch-native --with-openssl
Compile and install Squid:
make make install
Generate a private CA that the proxy will use for on‑the‑fly certificate creation:
cd /etc/squid mkdir ssl_cert chown squid:squid ssl_cert chmod 600 ssl_cert cd ssl_cert openssl req -new -newkey rsa:2048 -sha256 -days 365 -nodes -x509 -keyout myCA.pem -out myCA.pem
Optionally convert the CA to DER format:
openssl x509 -in myCA.pem -outform DER -out myCA.der
A minimal squid.conf that enables SSL‑bump, defines safe ports, ACLs, and access rules looks like the following:
# # Recommended minimum configuration: # # Example rule allowing access from your local networks. # Adapt to list your (internal) IP networks from where browsing should be allowed acl localnet src 10.0.0.0/8 # RFC1918 possible internal network acl localnet src 172.16.0.0/12 # RFC1918 possible internal network acl localnet src 192.168.0.0/16 # RFC1918 possible internal network acl localnet src fc00::/7 # RFC 4193 local private network range acl localnet src fe80::/10 # RFC 4291 link‑local machines acl localnet src 127.0.0.1 acl SSL_ports port 443 acl Safe_ports port 80 # http acl Safe_ports port 21 # ftp acl Safe_ports port 443 # https acl Safe_ports port 70 # gopher acl Safe_ports port 210 # wais acl Safe_ports port 1025-65535 # unregistered ports acl Safe_ports port 280 # http‑mgmt acl Safe_ports port 488 # gss‑http acl Safe_ports port 591 # filemaker acl Safe_ports port 777 # multiling http acl CONNECT method CONNECT sslproxy_cert_error allow all #disable this in production, it is dangerous but useful for testing sslproxy_flags DONT_VERIFY_PEER # Recommended minimum Access Permission configuration: http_access deny !Safe_ports http_access deny CONNECT !SSL_ports http_access allow localhost manager http_access deny manager #http_access deny to_localhost http_access allow localnet http_access allow localhost http_access deny all http_port 3128 #cache_dir ufs /var/cache/squid 100 16 256 coredump_dir /var/cache/squid http_port x.x.x.x:3129 ssl-bump \ cert=/etc/squid/ssl_cert/myCA.pem \ generate-host-certificates=on dynamic_cert_mem_cache_size=4MB https_port x.x.x.x:3130 ssl-bump intercept \ cert=/etc/squid/ssl_cert/myCA.pem \ generate-host-certificates=on dynamic_cert_mem_cache_size=4MB acl step1 at_step SslBump1 ssl_bump peek step1 ssl_bump stare all ssl_bump bump all always_direct allow all refresh_pattern ^ftp: 1440 20% 10080 refresh_pattern ^gopher: 1440 0% 1440 refresh_pattern -i (/cgi-bin/|\?) 0 0% 0 refresh_pattern . 0 20% 4320
Start the Squid service using your OS’s init system and verify it is listening on the configured ports:
sudo netstat -peant | grep ":3130"
Redirect inbound HTTPS traffic to the Squid instance with an iptables NAT rule (replace y.y.y.y with the public IP and x.x.x.x with the Squid host IP):
iptables -t nat -I PREROUTING -p tcp --dport y.y.y.y:443 -j DNAT --to x.x.x.x:3130
If client machines trust the generated root CA, the proxy will transparently intercept and forward all outbound connections.
Original sources: SSLTrust guide and IntelligentX article .
Architects Research Society
A daily treasure trove for architects, expanding your view and depth. We share enterprise, business, application, data, technology, and security architecture, discuss frameworks, planning, governance, standards, and implementation, and explore emerging styles such as microservices, event‑driven, micro‑frontend, big data, data warehousing, IoT, and AI architecture.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.