In this tutorial we’ll learn how to install Squid Proxy on Ubuntu 16.04. We will also install and configure its prerequisites. Squid is an open Open Source full-featured web proxy cache server application which provides proxy and cache services for Hyper Text Transport Protocol (HTTP), File Transfer Protocol (FTP), and other popular network protocols.
Squid can implement caching and proxying of Secure Sockets Layer (SSL) requests and caching of Domain Name Server (DNS) lookups, and perform transparent caching. It reduces bandwidth and improves response times by caching and reusing frequently-requested web pages. It has extensive access controls and makes a great server accelerator. A Squid proxy server is generally installed on a separate server than the Web server with the original files that works by tracking object use over the network. Squid will initially act as an intermediary, simply passing the client’s request on to the server and saving a copy of the requested object. If the same client or multiple clients request the same object before it expires from Squid’s cache, Squid can then immediately serve it, accelerating the download and saving bandwidth.
I recommend to use a minimal Ubuntu server setup as a basis for the tutorial, that can be a virtual or a root server image with an Ubuntu 16.04 minimal install from a web hosting company or you use our minimal server tutorial to install a server from scratch.
Install Squid Proxy on Ubuntu 16.04
Step 1. First, ensure your system and apt package lists are fully up-to-date by running the following:
apt-get update -y apt-get upgrade -y
Step 2. Installing Squid Proxy.
The installation of Squid proxy server on an Ubuntu server is pretty straightforward as its available in the Ubuntu repositories. Run the command below to install squid:
sudo apt-get install squid
Step 3. Squid Configuration.
After the Squid install completes, I suggest that you create a copy of the original config file created during the install as it is a helpful reference and allows you to rollback any changes:
cp /etc/squid/squid.conf /etc/squid/squid.conf.org
Squid listens on port 3128 by default and if you would like to change the default listening port you can do by to editing the ‘http_port’ directive in the configuration file:
### nano /etc/squid/squid.conf http_port 3128
Next to allow access to the HTTP proxy server from all IP addresses:
http_access allow all
Save and close and restart squid service by issuing below command:
systemctl restart squid
Step 4. Configure User and Password Authentication in Squid.
Open the squid configuration file to add following line:
nano /etc/squid/squid.conf auth_param basic program /usr/lib/squid/basic_ncsa_auth /etc/squid/passwd auth_param basic realm proxy acl authenticated proxy_auth REQUIRED http_access allow authenticated
Next, create a new empty file for storing squid credentials:
Then we will be using below command to generate password for a user like ‘rezkia’ that will going to access the squid proxy server:
htpasswd -c /etc/squid/passwd rezkia
After this restart your squid service so that the configuration can be updated:
systemctl restart squid
Step 5. Using Your Proxy.
Now that Squid is setup, you can use it as a forwarding proxy. Configure the “internet settings” of your web browser to use your proxy, including the user name and password that you generated earlier.
Congratulation’s! You have successfully install and configured Squid on your Ubuntu 16.04 LTS server. Thanks for using this tutorial for installing Squid Proxy on Ubuntu 16.04 system.