Sitemap

Squid Proxy Basic Setup

3 min read1 day ago

--

Starting from a new Ubuntu VM:

sudo apt-get update

sudo apt install squid

Edit the Squid config file:

sudo nano /etc/squid/squid.conf

Look for the section with ACLs. Mine looks like this after allowing my local subnet, 10.10.4.0/24.

Press enter or click to view image in full size

I also had to uncomment this line to allow localnet to communicate to any website. We will modify this later.

Press enter or click to view image in full size

I left the default port Squid listens on as 3128, but this can be changed.

Save changes, restart squid, and then check the running status of Squid.

Press enter or click to view image in full size

Configure the proxy settings on a device that will use Squid. I used a Windows VM.

Press enter or click to view image in full size

Attempt to connect to the Internet. Once successful, the log located at /var/log/squid/access.log will look like this.

Press enter or click to view image in full size

Useful commands:

1. Enable Squid to start automatically on boot

Get Jeff’s stories in your inbox

Join Medium for free to get updates from this writer.

sudo systemctl enable squid

2. Restart Squid

sudo systemctl restart squid

3. Stop Squid

sudo systemctl stop squid

4. Start Squid

sudo systemctl start squid

Whitelisting websites:

  1. Create a text file for the whitelisted websites. Adding “.” to the beginning of the is like a wildcard, (i.e. *.microsoft.com) so subdomains are included.

2. Edit /etc/squid/squid.conf

I added this line to the acl to define the whitelisted sites.

Press enter or click to view image in full size

Then I commented the line that allows localnet to reach any website, and added a new line to allow localnet only to the sites in the allowed_list.

Press enter or click to view image in full size

Testing confirmed I could reach https://microsoft.com, but I could not reach https://msn.com, so the whitlisting is working.

--

--