Building a Squid Proxy Server on Linux
This article explains how to install and configure a basic Squid proxy server on Linux and how to configure clients to use it.
Squid is a powerful caching proxy server that improves browsing performance, enables web filtering, and provides access control. Proper client configuration ensures traffic is routed through the proxy securely and effectively.
Step 1: Install Squid
Section titled “Step 1: Install Squid”On RHEL-based systems (AlmaLinux, Rocky, CentOS):
Section titled “On RHEL-based systems (AlmaLinux, Rocky, CentOS):”sudo dnf install squid -yOn Debian-based systems (Ubuntu):
Section titled “On Debian-based systems (Ubuntu):”sudo apt updatesudo apt install squid -yStep 2: Configure the Squid Proxy
Section titled “Step 2: Configure the Squid Proxy”Edit /etc/squid/squid.conf:
sudo nano /etc/squid/squid.confMinimal working config:
http_port 3128
acl localnet src 192.168.0.0/16http_access allow localnethttp_access deny all
dns_v4_first onRecommended tuning additions:
cache_mem 64 MBmaximum_object_size_in_memory 512 KBmaximum_object_size 20 MBaccess_log /var/log/squid/access.logcache_log /var/log/squid/cache.logStep 3: Enable and Start Squid
Section titled “Step 3: Enable and Start Squid”sudo systemctl enable --now squidStep 4: Configure the Firewall
Section titled “Step 4: Configure the Firewall”firewalld:
Section titled “firewalld:”sudo firewall-cmd --add-port=3128/tcp --permanentsudo firewall-cmd --reloadsudo ufw allow 3128/tcpStep 5: Configure Client Devices
Section titled “Step 5: Configure Client Devices”On Linux (temporary shell setting):
Section titled “On Linux (temporary shell setting):”export http_proxy="http://<squid-ip>:3128"export https_proxy="http://<squid-ip>:3128"On Linux (persistent system-wide):
Section titled “On Linux (persistent system-wide):”Edit /etc/environment:
http_proxy="http://<squid-ip>:3128"https_proxy="http://<squid-ip>:3128"On Windows (PowerShell, current user only):
Section titled “On Windows (PowerShell, current user only):”netsh winhttp set proxy <squid-ip>:3128To reset:
netsh winhttp reset proxyStep 6: Test the Connection
Section titled “Step 6: Test the Connection”From a client:
curl -x http://<squid-ip>:3128 http://example.comOn the Squid server:
sudo tail -f /var/log/squid/access.logConclusion
Section titled “Conclusion”This setup provides a simple, functional proxy server and client configuration without relying on PAC files. It offers centralized control, logging, and flexibility for network traffic management.