Linux Commands and Scripts

Install Squid Proxy on Ubuntu 20.04

In this article, we’ll explain how to install Squid Proxy on Ubuntu 20.04. The article will guide you the installation and configuration process.

Squid proxy is a caching and forwarding HTTP web proxy. It has a wide variety of uses, including speeding up a web server by caching repeated requests, caching web, DNS and other computer network lookups. Squid proxy is a web proxy application that can be installed and set up on Linux and other Unix-like operating systems.

Prerequisites

Install Squid Proxy on Ubuntu 20.04

Step 1 – Keep the server updated

# apt update -y

# apt upgrade -y

Step 2 – Install Squid Proxy

# apt install squid -y

Step 3 – Start and enable Squid service

To start and enable service of Squid proxy, execute following commands:

# systemctl start squid

# systemctl enable squid

Step 4 – Configure Squid proxy

Open Squid proxy configuration file

# vi /etc/squid/squid.conf

Search http_access deny all in the file and replace it with http_access allow all.

Save and exit.

Now, restart the Squid service to reflect the changes.

# systemctl restart squid

ACL (Access Control List) Configuration (Optional)

Squid proxy allows you to control the access to different websites (web traffic) by either allowing or blocking them. To do so, follow follow steps:

Open Squid proxy configuration file

# vi /etc/squid/squid.conf

Go to the line acl CONNECT method CONNECT.

Write the ACL (access control list) to block the websites you want.

acl block_websites dstdomain .facebook.com .youtube.com .etc.com

Then write the deny statement after that.

http_access deny block_websites

If you want to control over downloading specific files like audio or video files, use following method:

Add this lines

acl  media_files  urlpath_regex -i  \.(mp3|mp4|FLV|AVI|MKV)

Replace the extensions as per your requirement.

Then write the deny statement after that.

http_access deny media_files

Now, restart the Squid service to reflect the changes.

# systemctl restart squid

That’s it. We have successfully installed and configured Squid Proxy.

In this article, we have seen how to install Squid Proxy on Ubuntu 20.04

Related Articles