How to Install and Configure Squid Proxy in Ubuntu 20.4.1

To Install and configure Squid proxy server in Ubuntu 20.4.1

Introduction:

Squid is a web proxy cache server that provides proxy and cache services for HTTP (HyperText Transport Protocol), FTP (File Transfer Protocol), and other network protocols.

Installation process:

Run lsb_release command to check the installed version of OS as follows.

root@linuxhelp:~#  lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 20.04.1 LTS
Release:	20.04
Codename:	focal

Install Squid:

To install Squid enter the mentioned command:

root@linuxhelp:~# apt install squid
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  libdbi-perl libecap3 squid-common squid-langpack
Suggested packages:
  libclone-perl libmldbm-perl libnet-daemon-perl libsql-statement-perl
  squidclient squid-cgi squid-purge resolvconf smbclient winbind
The following NEW packages will be installed:
  libdbi-perl libecap3 squid squid-common squid-langpack
0 upgraded, 5 newly installed, 0 to remove and 180 not upgraded.
Need to get 3,666 kB of archives.
After this operation, 15.6 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://in.archive.ubuntu.com/ubuntu focal/main amd64 libecap3 amd64 1.0.1-3.2ubuntu1 [17.4 kB]

After completing the above step, open the squid configuration file by using the following command:

root@linuxhelp:~# vim /etc/squid/squid.conf
#
# INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
#
include /etc/squid/conf.d/*
acl localnet src 192.168.7.237
acl blocksite dstdomain "/etc/squid/blocksite"
http_access deny blocksite
http_access allow localnet
# Example rule allowing access from your local networks.
# Adapt localnet in the ACL section to list your (internal) IP networks
# from where browsing should be allowed
#http_access allow localnet
http_access allow localhost

# And finally deny all other access to this proxy
http_access allow all

After the configuration is completed. Let open block site file to block the particular website by using the following command.

root@linuxhelp:~# vim /etc/squid/blocksite
facebook.com

Once the above step is completed, restart the squid server by using the below command

root@linuxhelp:~# systemctl restart squid

After completed open the client machine browser and follow the below steps Go to the settings Select Advanced option Open Proxy settings Turn ON proxy server Enter IP address and Port number Facebook is not working Amazon is working

With this method the Installation process of SQUID on Ubuntu comes to end.

FAQ
Q
How to check the status of the squid server?
A
To check the status of the squid server use # systemctl status squid.
Q
What is the default port number of the squid server?
A
The default port number of the squid server is 3128
Q
How to restart the squid server?
A
To restart the squid server use # systemctl
Q
How to open the squid configuration file?
A
To open the squid configuration file use # vim /etc/squid/squid.conf
Q
How to install the squid server on ubuntu OS?
A
To install squid server on ubuntu OS use # apt install squid.