How to Install Squid Proxy on CentOS 7

r00t January 29, 2018

Install Squid Proxy on CentOS 7

In this tutorial we’ll learn how to install Squid Proxy on CentOS 7. 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.

I recommend to use a minimal CentOS server setup as a basis for the tutorial, that can be a virtual or a root server image with an CentOS 7 minimal install from a web hosting company or you use our minimal server tutorial to install a server from scratch.

Install Squid Proxy on CentOS 7

Step 1. First, ensure your system and apt package lists are fully up-to-date by running the following:

yum -y install epel-release
yum -y update

Step2. Installing Squid Proxy.

Install Squid and related packages is now as simple as running just one command:

yum -y install squid

Once you install Squid, you can start the program immediately using the following command:

systemctl start squid
systemctl enable squid

Step 3. Squid Configuration.

Squid can be easily configured by editing the global configuration file /etc/squid/squid.conf. To edit the configuration file run following command:

nano /etc/squid/squid.conf

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:

http_port 3128

Step 4. Configure User and Password Authentication in Squid.

Add the following lines into the configuration file under the access control lists of ports:

### 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:

touch /etc/squid/passwd

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 Squid on your CentOS 7 server. Thanks for using this tutorial for installing Squid Proxy on CentOS 7 system.

The Tags:

Leave a Comment

Comments are closed.