Squid with TLS Support on Ubuntu 26.04: squid-openssl or Build from Source
Ubuntu no longer needs a recompiled Squid for TLS. Install squid-openssl, configure an https_port, test it with curl, or rebuild the package with your own options.
This guide gives you a Squid proxy on Ubuntu 26.04 LTS that accepts connections from clients over TLS on an https_port. On current Ubuntu you no longer have to compile Squid to get TLS support: the archive carries a ready-made OpenSSL build in the squid-openssl package. The steps cover installing it, configuring and testing the TLS listener, and, for the cases where you really need different build options, rebuilding the Ubuntu package from source. Ubuntu 24.04 LTS works the same way; the differences are noted where they exist.
Ubuntu 12.04 and 14.04, where the squid3 package had to be recompiled with --enable-ssl, are long past end of life. The package, the service and the configuration directory are now all called squid, and the build switch is --with-openssl.
Which package you need
| Package | TLS library | Use it when |
|---|---|---|
squid | GnuTLS | You need a plain forward proxy or cache |
squid-openssl | OpenSSL | You want the OpenSSL feature set, including SSL-Bump and its certificate helper |
Both builds proxy HTTPS sites for clients through CONNECT tunnels on the normal http_port; that never required TLS support in Squid. The TLS build matters for two other jobs: encrypting the connection between the client and the proxy itself (https_port), and inspecting HTTPS traffic (SSL-Bump). This guide uses squid-openssl, which is in the universe component. Ubuntu 26.04 ships Squid 7 and Ubuntu 24.04 ships Squid 6.
Requirements
- A server running Ubuntu 26.04 LTS or 24.04 LTS and a user with
sudorights. - A DNS name for the proxy, for example
proxy.example.com, pointing to the server. - A TLS certificate and private key for that name. A certificate from a public CA such as Let's Encrypt saves you from distributing a CA file to every client.
Install Squid with OpenSSL support
sudo apt update
sudo apt install squid-opensslIf squid is already installed, this command replaces the GnuTLS build and keeps your /etc/squid/squid.conf. Confirm which build is running:
squid -v | tr ' ' '\n' | grep -E 'with-(openssl|gnutls)'The output should include '--with-openssl'. The first line of squid -v shows the Squid version.
Configure the TLS listener
Put the certificate and key where the proxy user, which Squid runs as, can read them. This example copies a Let's Encrypt certificate; adjust the source paths to wherever your certificate lives.
sudo install -d -o root -g proxy -m 750 /etc/squid/tls
sudo install -o root -g proxy -m 640 /etc/letsencrypt/live/proxy.example.com/fullchain.pem /etc/squid/tls/proxy.crt
sudo install -o root -g proxy -m 640 /etc/letsencrypt/live/proxy.example.com/privkey.pem /etc/squid/tls/proxy.keyRepeat the copy and reload Squid whenever the certificate is renewed, for example from a renewal hook of your ACME client.
The packaged squid.conf includes every file in /etc/squid/conf.d/ ahead of its final http_access deny all rule, so you can keep your settings in a separate file:
sudo nano /etc/squid/conf.d/tls-proxy.confAdd the listener and a rule for the clients that may use the proxy. Replace 203.0.113.0/24 with your own network or address.
https_port 3129 tls-cert=/etc/squid/tls/proxy.crt tls-key=/etc/squid/tls/proxy.key
acl trusted_clients src 203.0.113.0/24
http_access allow trusted_clientstls-cert= is mandatory on an https_port. If you leave out tls-key=, Squid expects the private key in the same PEM file as the certificate. Never allow all here: an open proxy on a public address is found and abused within hours.
Check the syntax and restart:
sudo squid -k parse
sudo systemctl restart squid
sudo systemctl status squid --no-pagerConfirm that both ports are open. Port 3128 is the plain http_port from the default configuration, port 3129 the new TLS listener.
sudo ss -tlnp | grep squidIf you use UFW, allow the TLS port from your client network only:
sudo ufw allow from 203.0.113.0/24 to any port 3129 proto tcpIf clients should only ever use the encrypted listener, change the default line in /etc/squid/squid.conf to http_port 127.0.0.1:3128 so the plain port is reachable from the server itself only.
Test from a client
curl can talk to a proxy over TLS when the proxy URL starts with https://:
curl -I --proxy https://proxy.example.com:3129 https://www.ubuntu.com/A response with an HTTP status line from the target site means the tunnel works. With a self-signed or private-CA certificate, add --proxy-cacert /path/to/ca.pem. On the server, the request shows up in the access log:
sudo tail /var/log/squid/access.logBrowsers do not offer a field for a TLS proxy in their manual settings. Firefox and Chromium-based browsers accept one through a proxy auto-configuration (PAC) file whose function returns HTTPS proxy.example.com:3129.
Rebuild the package from source
Only do this if you need a compile-time option that neither Ubuntu build has. A self-built package no longer receives security updates from the archive, so you take over the job of rebuilding it for every Squid security fix.
Enable source repositories. On Ubuntu 24.04 and later the sources are defined in /etc/apt/sources.list.d/ubuntu.sources; change each Types: deb line to Types: deb deb-src:
sudo sed -i 's/^Types: deb$/Types: deb deb-src/' /etc/apt/sources.list.d/ubuntu.sources
sudo apt updateInstall the build tools and Squid's build dependencies:
sudo apt install build-essential devscripts fakeroot
sudo apt build-dep squidDownload the source package into a working directory as your normal user:
mkdir ~/squid-build && cd ~/squid-build
apt source squid
cd squid-*/The configure options are set in debian/rules. Open the file, find the list of ./configure flags, and add or change the option you need:
nano debian/rulesRecord the change with a local version suffix, so you can tell your build from the archive's, and build unsigned binary packages:
dch --local +custom "Rebuild with custom configure options"
dpkg-buildpackage -us -uc -bThe build runs for a while and writes the .deb files to the parent directory. Install the ones you need, at minimum the common files and the flavour you built:
cd ..
ls *.deb
sudo apt install ./squid-common_*.deb ./squid-openssl_*.debStop APT from replacing your build with the archive version on the next upgrade:
sudo apt-mark hold squid-openssl squid-commonVerify with squid -v that your option appears in the configure line.
Troubleshooting
squid -k parserejectshttps_port: the directive needs a build with--with-opensslor--with-gnutls. Checksquid -vand which package is installed withdpkg -l 'squid*'.- Squid does not start after adding the certificate: the
proxyuser cannot read the key. Check withsudo -u proxy head -c 1 /etc/squid/tls/proxy.keyand readsudo journalctl -u squid -band/var/log/squid/cache.log. TCP_DENIED/403in the access log: the client address does not match youracl, or the rule was placed afterhttp_access deny all.- curl reports a certificate error for the proxy: the name in the proxy URL does not match the certificate, or the chain file lacks the intermediate certificate.
The option reference is in the Squid documentation for https_port and http_port.
Frequently asked questions
Do I need this to reach HTTPS websites through Squid?
No. A browser asks the proxy for a CONNECT tunnel and then speaks TLS directly with the website; any Squid build handles that on the ordinary http_port. An https_port additionally encrypts the conversation with the proxy, which hides the requested host names and any proxy credentials from the network between client and proxy.
Why not install Squid with ./configure && make install from the upstream tarball?
You can, but you lose the systemd unit, log rotation, the AppArmor profile and the file layout that the Ubuntu package sets up, and nothing tracks the installed files. Rebuilding the distribution's source package changes only the options you care about and leaves the rest of the integration intact.
Does https_port on port 443 turn Squid into a transparent HTTPS proxy?
No. Without a mode keyword, an https_port is a forward-proxy port that clients must be configured to use. Intercepting and decrypting HTTPS traffic is SSL-Bump, a separate feature that requires your own CA certificate installed on every client and, in most places, the informed consent of the users.
Is authentication still needed when the proxy uses TLS?
TLS protects the connection; it does not decide who may use the proxy. Restrict access by source address as shown, or add proxy authentication with auth_param if clients connect from changing addresses. With an https_port, Basic authentication credentials are at least no longer sent in clear text.