Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

Install and Configure a Squid Proxy on Ubuntu

Set up Squid as a caching proxy, allow your network, and change the port and cache settings.

VPS and Cloud Servers2 min read7 screenshots

What a proxy is

A proxy server sits between your users and the internet. It can:

  • Improve security by hiding internal machines.
  • Protect privacy.
  • Control and filter what users can open.
  • Save bandwidth and speed up access by caching.

Squid is a free, popular caching proxy. It supports HTTP, HTTPS and FTP, and can be tuned in many ways.

Install Squid

Update the system:

sudo apt update && sudo apt full-upgrade
Updating the system

Install Squid:

sudo apt install squid -y
Installing Squid

Check that it runs:

sudo systemctl status squid
The status of the Squid service

Configure Squid

Make a backup of the original file, then edit it:

sudo cp /etc/squid/squid.conf /etc/squid/squid.conf.backup
sudo nano /etc/squid/squid.conf

Allow your network. Define an ACL for your network and allow it. Put the http_access allow line above the final http_access deny all:

acl localnet src 192.168.1.0/24
http_access allow localnet
Allowing access from your network

Change the port. Find http_port 3128 and change the number if you want another port. Open that port in your firewall.

Changing the proxy port

Turn on caching. Set the cache folder and size, and the memory used for caching:

cache_dir ufs /var/spool/squid 10000 16 256
cache_mem 256 MB
Cache settings

10000 is the cache size in MB.

Save the file and restart Squid:

sudo systemctl restart squid
Restarting Squid

Use the proxy

On your client, set the proxy to the IP address of the server and port 3128 (or your port). Test it:

curl -x http://server_ip:3128 http://example.com

Read the logs

sudo tail -f /var/log/squid/access.log
sudo tail -f /var/log/squid/cache.log

Benefits of Squid

  • Faster pages through caching.
  • Less bandwidth use.
  • Better security and access control.
  • Content filtering with ACLs.
  • Open source and highly configurable.
Warning: Never make an open proxy. Always limit access to your own network or require a login. Open proxies are abused by spammers.

Quick recap

  • Install squid, allow your network with an ACL, and restart the service.
  • Change the port and cache size in squid.conf.
  • Read access.log to see what happens.