Installing Squid 4.10 from Source.


Getting Our System Ready For Compiling From Source.


Firstly login to your linux system with the user you created (sysadmin in my Example screenshots), then elevate your privileges to root by typing sudo -s , type your password and press Enter.

Now we need to enable access to Ubuntu’s Source repositories.

Type nano /etc/apt/sources.list and press Enter

Uncomment (remove the #) in front of all the lines that start with deb & deb-src, press CTRL + O then Enter to save, and CTRL + X to exit.

We also need to update our server’s repository cache, so it is aware of the new repositories contents that we just enabled.

Type apt update and press Enter.

Next, we need to instal some packages necessary to build Squid from source. We can’t use the packages in Ubuntu’s repository because the do not include support for running Squid as an SSL Proxy.

Type apt install build-essential fakeroot devscripts
gawk gcc-multilib dpatch openssl libssl-dev pkg-config
, and press
Enter.


Compiling Squid from Source


Next up, we need to download the squid source code we are going to use. I’ve done this in a script for ease of execution. Let’s create the script then execute it.

Type  nano buildsquid.bash and press Enter

Type out the script in the screenshot exactly as is, and save & exit.

Next, run the script by typing bash buildsquid.bash and
press Enter.

Next, we need to enable SSL Support, so that when we start compiling squid is built with SSL support enabled.

Type cd ~/build/squid/squid-4.10/ && nano debian/rules and press Enter.

Modify the line that reads –enable-icap-client / to look as in the screenshot above. Save the file & exit.

Next up, we need to modify one of the source files before compiling squid.  Due to some sites using Round-Robin DNS, squid incorrectly picks up these sites as forgeries when running as an SSL proxy in transparent mode (not an issue if running in explicit mode (Put proxy settings in browser or deploying via WPAD)).

The file we need to modify is in the src directory under ~/build/squid/squid-4.10/ and is called client_side_request.cc. open it with nano and look for the lines below (if you are using squid 4.10 from the DL source in this howto – the lines we are looking for will be on line 540 of the file):

debugs(85, 3, HERE << “validate IP ” <<
clientConn->local << ” non-match from Host: IP ” <<
ia->in_addrs[i]);

        }

After the curly-bracket, on a new line type the following:

        http->request->flags.hostVerified = true;

        http->doCallouts();

        return;

The applicable section of the file should then look like the
image below:

Now we can compile / build or .deb packages we will use to
install Squid.

Type dpkg-buildpackage -rfakeroot -b -us -uc and
press Enter.

Let this run through, it will take some time – how much is
dependent on your hardware.

Once it is done, you can cd one directory up,  as that is
where our installation files were created.

Type  cd.. and Enter then ls -lh
and Enter to list the content of the directory. The .deb files you see, are the
ones our previous command created.

We also need to install just squid’s language pack from
Ubuntu’s repository, as well as apache. To do this type apt install
squid-langpack apache2
and press Enter. Then, once that is done – type dpkg –i squid*.deb to install squid.

And that’s it, squid is installed!

Next up: Installing SARG (Squid Reporting Tool)