Skip to content

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.

On RHEL-based systems (AlmaLinux, Rocky, CentOS):

Section titled “On RHEL-based systems (AlmaLinux, Rocky, CentOS):”
Terminal window
sudo dnf install squid -y
Terminal window
sudo apt update
sudo apt install squid -y

Edit /etc/squid/squid.conf:

Terminal window
sudo nano /etc/squid/squid.conf

Minimal working config:

Terminal window
http_port 3128
acl localnet src 192.168.0.0/16
http_access allow localnet
http_access deny all
dns_v4_first on

Recommended tuning additions:

Terminal window
cache_mem 64 MB
maximum_object_size_in_memory 512 KB
maximum_object_size 20 MB
access_log /var/log/squid/access.log
cache_log /var/log/squid/cache.log
Terminal window
sudo systemctl enable --now squid
Terminal window
sudo firewall-cmd --add-port=3128/tcp --permanent
sudo firewall-cmd --reload
Terminal window
sudo ufw allow 3128/tcp
Terminal window
export http_proxy="http://<squid-ip>:3128"
export https_proxy="http://<squid-ip>:3128"

Edit /etc/environment:

Terminal window
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):”
Terminal window
netsh winhttp set proxy <squid-ip>:3128

To reset:

Terminal window
netsh winhttp reset proxy

From a client:

Terminal window
curl -x http://<squid-ip>:3128 http://example.com

On the Squid server:

Terminal window
sudo tail -f /var/log/squid/access.log

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.