How to Install Squid Proxy on Ubuntu 20.04. In this article we will introduce what is a Squid Proxy with its feature and illustrate the installation steps on Ubuntu 20.04. Let’s start!
What is Squid Proxy
Squid is a Unix based proxy server used for caching Internet content, which is closer to the requestor than its original point of origin. It is capable of supporting multiple web objects as well as those that can be accessed via HTTP and FTP. This process of caching frequently searched web pages, media files and other content increases the response time and eliminates bandwidth bottlenecks.
Squid Proxy server is installed on different servers and tracks objects usage across different networks. It acts as an intermediary as it only sends the client’s request to the server and keeps a copy of the requested objects. Before exiting the Squid cache, if the same client or multiple clients requests the same object, it serves it immediately to them, thereby increasing the downloading time and saving the bandwidth.
In a nutshell, Squid Proxy is a server that is available as free and open source software and can be used under the Free Software Foundation’s GNU General Public License (GPL). The Squid was originally designed to run on Unix based systems but can also run on Windows machines.
Deploying a Squid Proxy server provides you with the following benefits:
Caching Web – It speeds up a web server by caching repeated requests so that they can be handled locally instead of heading out to the source.
Security Tool – Squid helps in increasing network security by filtering incoming traffic. This way, it restricts external clients from passing through the proxy without authorization. It also stops malicious websites from attacking any users that may have stumbled onto some malicious code.
Authentication – You can also configure Squid to define the Access Control List (ACL), which sets the permission of who can access the proxy resources.
Domain Name System (DNS) Server – It can also be used as a Doman Name System (DNS) Server that is proven to be effective in resolving hostnames with the help of DNS third party applications or through a built in internal DNS client.
Load Sharing – During traffic surges or unexpected bandwidth clogging, Squid Proxy can be used to configure or distribute loads over intercommunicating hierarchies of proxy servers. This way, the response time becomes faster and the traffic is decongested.
Corporate Censorship – Squid is a proxy server that either allows or denies access to specific websites. It configures the permissions based on the time of the workday.
In this post, we will show you how to install Squid Proxy on Ubuntu 20.04.
Squid Proxy allows you to restrict the client to access the internet base on the authentication method. In this section, we will set up password based and IP based authentication.
Configure IP Based Authentication
Squid Proxy allows you to configure Squid to restrict users based on the user’s IP address. You can configure the IP based authentication by editing the Squid main configuration file:
nano /etc/squid/squid.conf
Add the following lines at the beginning of the file:
You can also configure Squid Proxy to restrict users based on the username and password to access the internet. First, install the Apache Utils package with the following command:
apt-get install apache2-utils -y
Next, create a user named host1 and set a password with the following command:
htpasswd /etc/squid/passwd host1
Set the password as shown below:
New password:
Re-type new password:
Adding password for user host1
Next, create a second user named host2 and set a password:
htpasswd /etc/squid/passwd host2
Set a password as shown below:
New password:
Re-type new password:
Adding password for user host2
Please edit the Squid configuration file:
nano /etc/squid/squid.conf
Add the following lines at the beginning of the file:
Next, you will also need to edit the Squid configuration file and define some rules to mask client IP addresses:
nano /etc/squid/squid.conf
Add the following lines at the beginning of the file:
forwarded_for off
request_header_access Allow allow all
request_header_access Authorization allow all
request_header_access WWW-Authenticate allow all
request_header_access Proxy-Authorization allow all
request_header_access Proxy-Authenticate allow all
request_header_access Cache-Control allow all
request_header_access Content-Encoding allow all
request_header_access Content-Length allow all
request_header_access Content-Type allow all
request_header_access Date allow all
request_header_access Expires allow all
request_header_access Host allow all
request_header_access If-Modified-Since allow all
request_header_access Last-Modified allow all
request_header_access Location allow all
request_header_access Pragma allow all
request_header_access Accept allow all
request_header_access Accept-Charset allow all
request_header_access Accept-Encoding allow all
request_header_access Accept-Language allow all
request_header_access Content-Language allow all
request_header_access Mime-Version allow all
request_header_access Retry-After allow all
request_header_access Title allow all
request_header_access Connection allow all
request_header_access Proxy-Connection allow all
request_header_access User-Agent allow all
request_header_access Cookie allow all
request_header_access All deny all
Save and close the file then restart the Squid Proxy service to apply the configuration changes:
At this point, Squid Proxy is installed and configured with password based authentication. Now, it’s time to test the Squid Proxy server.
Go to the remote system, open the Mozilla web browser, and click on the Edit => Preferences:
2. Scroll down the page and click on the Settings under the NetworkSettings:
3. Select the Manual proxy configuration, type your Squid Proxy server IP address, Squid Proxy port, select the Use this proxy server for all protocols check box and click on the OK button to save the settings.
4. Now, open another tab in your web browser and type the URL https://www.whatismyip.com/. You will be asked to authenticate your Squid Proxy server:
5. Provide your username, password, and click on the Signin button. Once you are authenticated successfully, you should see the Whatismyipaddress page:
6. You can see the Squid Proxy server IP address on the above screen. That means all internet traffics are passed through the Proxy server.
How to Install Squid Proxy on Ubuntu 20.04 Conclusion
In this post, we explained how to install the Squid Proxy server on Ubuntu 20.04. We also explained how to configure IP and password based authentication in Squid. For more advanced configuration, visit the Squid Proxy documentation page.
I am a fan of open source technology and have more than 10 years of experience working with Linux and Open Source technologies. I am one of the Linux technical writers for Cloud Infrastructure Services.
51vote
Article Rating
Subscribe
Login and comment with
I allow to create an account
When you login first time using a Social Login button, we collect your account public profile information shared by Social Login provider, based on your privacy settings. We also get your email address to automatically create an account for you in our website. Once your account is created, you'll be logged-in to this account.
DisagreeAgree
Login and comment with
I allow to create an account
When you login first time using a Social Login button, we collect your account public profile information shared by Social Login provider, based on your privacy settings. We also get your email address to automatically create an account for you in our website. Once your account is created, you'll be logged-in to this account.