Squid Web Cache Server on Arch Linux

Squid Web Proxy Caching on Arch Linux

Squid is a web caching proxy that can reduce bandwidth and improve web browsing speed and response times by caching frequently requested resources. It can also be used as an antivirus, content filter and an ad blocker with various plugins.

 

Install Squid

Install from the official repository.

sudo pacman -S squid

 

Configure Squid

Open the configuration file.

sudo nano /etc/squid/squid.conf

 

Modify or add setting in the configuration file.

cache_mem 128 MB
maximum_object_size 64 MB
#dns_defnames on

acl localnet src 192.168.0.0/24

http_access allow localnet
http_access allow localhost


cache_dir ufs /var/cache/squid 10000 16 256

Specify cache_mem value to set a nominal cache size on disk. Single file size is limited with maximum_object_size option. Networks that are allowed to connect to the proxy are defined with acl localnet src option followed by the IP address or address range and the subnet mask in CIDR notation. HTTP caching is enabled with http_access allow option followed by the variable defined above.

Caching directory is defined with cache_dir option that consists of filesystem that should be ufs followed by the path which is /var/cache/squid by default. The 3 numbers are the nominal cache directory size in Mb, number of first level directories and second level directories that will be created respectively.

 

Create cache directories.

sudo squid -z

 

Check the configuration is valid.

sudo squid -k check

No output means no issues were detected. Systemd script should be started before this command is executed or squid: ERROR: No running copy error will be returned.

 

Run Squid

Start systemd service.

sudo systemctl start squid

 

Enable systemd service to run on boot.

sudo systemctl enable squid

 

Configure Windows Proxy Clients

In Windows go to Control Panel -> Network and Internet -> Internet Options. From the window that appears navigate to Connections tab and click LAN settings. This is also accessible from Chrome browser by navigating to Settings -> Show advanced settings... -> Change proxy settings....

In the Proxy server section tick the Use a proxy server for your LAN (These settings will not apply to dial-up or VPN connections). In the Address field enter the IP address of the proxy server and port in the Port field. Default port is 3128 unless it has been changed manually in the configuration file. Optionally tick Bypass proxy server for local addresses checkbox. This can also be configured on the proxy side. Apply the settings and web requests should go through to the proxy from now on.