How to Install and Configure Squid Proxy Server on CentOS 6.2

In web servers, the ability to install and configure a Squid Proxy Server on CentOS 6.2 is an essential skill for any webmaster or website administrator. Squid is a caching proxy server that acts as an intermediary between the user and the web, enhancing performance and reducing bandwidth usage. It can also function as a content accelerator or reverse proxy, serving cached versions of pages to fulfill requests.

This tutorial will guide you through the process of installing and configuring a Squid 3 Proxy Server on CentOS 6.2.

For more in-depth information on various web servers, you can visit our pages on the best web servers, Apache, Nginx, and LiteSpeed.

Step 1: Installing Squid Proxy

The first step in setting up a Squid Proxy Server on CentOS 6.2 is to install the Squid proxy using the yum command. This installation is performed using a local yum repository. To install Squid, you can use the following command:

[root@centos62 ~]# yum install squid -y

This command will install Squid and all its dependencies. Once the installation is complete, you can proceed to the next step.

[root@centos62 ~]# yum install squid -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: centos.maulvi.net
 * extras: centos.maulvi.net
 * updates: centos.maulvi.net
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package squid.i686 7:3.1.10-1.el6_2.1 will be installed
--> Processing Dependency: perl(Getopt::Long) for package: 7:squid-3.1.10-1.el6_2.1.i686
--> Processing Dependency: perl(integer) for package: 7:squid-3.1.10-1.el6_2.1.i686
--> Processing Dependency: perl(Pod::Usage) for package: 7:squid-3.1.10-1.el6_2.1.i686
--> Processing Dependency: perl(DBI) for package: 7:squid-3.1.10-1.el6_2.1.i686
--> Processing Dependency: perl(Digest::MD5) for package: 7:squid-3.1.10-1.el6_2.1.i686
--> Processing Dependency: perl(vars) for package: 7:squid-3.1.10-1.el6_2.1.i686
--> Processing Dependency: libltdl.so.7 for package: 7:squid-3.1.10-1.el6_2.1.i686
--> Processing Dependency: perl(strict) for package: 7:squid-3.1.10-1.el6_2.1.i686
--> Processing Dependency: /usr/bin/perl for package: 7:squid-3.1.10-1.el6_2.1.i686
--> Processing Dependency: perl(Getopt::Std) for package: 7:squid-3.1.10-1.el6_2.1.i686
--> Processing Dependency: perl(Net::POP3) for package: 7:squid-3.1.10-1.el6_2.1.i686
--> Running transaction check
---> Package libtool-ltdl.i686 0:2.2.6-15.5.el6 will be installed
---> Package perl.i686 4:5.10.1-119.el6_1.1 will be installed
--> Processing Dependency: perl-libs = 4:5.10.1-119.el6_1.1 for package: 4:perl-5.10.1-119.el6_1.1.i686
--> Processing Dependency: perl-libs for package: 4:perl-5.10.1-119.el6_1.1.i686
--> Processing Dependency: perl(Pod::Simple) for package: 4:perl-5.10.1-119.el6_1.1.i686
--> Processing Dependency: libperl.so for package: 4:perl-5.10.1-119.el6_1.1.i686
--> Processing Dependency: perl(version) for package: 4:perl-5.10.1-119.el6_1.1.i686
--> Processing Dependency: perl(Module::Pluggable) for package: 4:perl-5.10.1-119.el6_1.1.i686
---> Package perl-DBI.i686 0:1.609-4.el6 will be installed
--> Running transaction check
---> Package perl-Module-Pluggable.i686 1:3.90-119.el6_1.1 will be installed
---> Package perl-Pod-Simple.i686 1:3.13-119.el6_1.1 will be installed
--> Processing Dependency: perl(Pod::Escapes) >= 1.04 for package: 1:perl-Pod-Simple-3.13-119.el6_1.1.i686
---> Package perl-libs.i686 4:5.10.1-119.el6_1.1 will be installed
---> Package perl-version.i686 3:0.77-119.el6_1.1 will be installed
--> Running transaction check
---> Package perl-Pod-Escapes.i686 1:1.04-119.el6_1.1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

====================================================================================================
 Package                     Arch       Version                    Repository                  Size
====================================================================================================
Installing:
 squid                       i686       7:3.1.10-1.el6_2.1         updates                    1.7 M
Installing for dependencies:
 libtool-ltdl                i686       2.2.6-15.5.el6             CentOS6.2-Repository        45 k
 perl                        i686       4:5.10.1-119.el6_1.1       CentOS6.2-Repository       9.7 M
 perl-DBI                    i686       1.609-4.el6                CentOS6.2-Repository       705 k
 perl-Module-Pluggable       i686       1:3.90-119.el6_1.1         CentOS6.2-Repository        37 k
 perl-Pod-Escapes            i686       1:1.04-119.el6_1.1         CentOS6.2-Repository        30 k
 perl-Pod-Simple             i686       1:3.13-119.el6_1.1         CentOS6.2-Repository       209 k
 perl-libs                   i686       4:5.10.1-119.el6_1.1       CentOS6.2-Repository       590 k
 perl-version                i686       3:0.77-119.el6_1.1         CentOS6.2-Repository        49 k

Transaction Summary
====================================================================================================
Install       9 Package(s)

Total download size: 13 M
Installed size: 38 M
Downloading Packages:
(1/9): squid-3.1.10-1.el6_2.1.i686.rpm                                       | 1.7 MB     00:14
----------------------------------------------------------------------------------------------------
Total                                                               881 kB/s |  13 MB     00:15
warning: rpmts_HdrFromFdno: Header V4 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Importing GPG key 0xC105B9DE:
 Userid : CentOS-6 Key (CentOS 6 Official Signing Key) 
 Package: centos-release-6-2.el6.centos.7.i686 (@anaconda-CentOS-201112130233.i386/6.2)
 From   : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : 1:perl-Pod-Escapes-1.04-119.el6_1.1.i686                                         1/9
  Installing : 3:perl-version-0.77-119.el6_1.1.i686                                             2/9
  Installing : 4:perl-libs-5.10.1-119.el6_1.1.i686                                              3/9
  Installing : 1:perl-Pod-Simple-3.13-119.el6_1.1.i686                                          4/9
  Installing : 1:perl-Module-Pluggable-3.90-119.el6_1.1.i686                                    5/9
  Installing : 4:perl-5.10.1-119.el6_1.1.i686                                                   6/9
  Installing : perl-DBI-1.609-4.el6.i686                                                        7/9
  Installing : libtool-ltdl-2.2.6-15.5.el6.i686                                                 8/9
  Installing : 7:squid-3.1.10-1.el6_2.1.i686                                                    9/9

Installed:
  squid.i686 7:3.1.10-1.el6_2.1

Dependency Installed:
  libtool-ltdl.i686 0:2.2.6-15.5.el6             perl.i686 4:5.10.1-119.el6_1.1
  perl-DBI.i686 0:1.609-4.el6                    perl-Module-Pluggable.i686 1:3.90-119.el6_1.1
  perl-Pod-Escapes.i686 1:1.04-119.el6_1.1       perl-Pod-Simple.i686 1:3.13-119.el6_1.1
  perl-libs.i686 4:5.10.1-119.el6_1.1            perl-version.i686 3:0.77-119.el6_1.1

Complete!

Step 2: Configuring Server Hosts File

The next step is to configure the server hosts file. This can be done using the vi editor. The hosts file should look something like this:

[root@centos62 ~]# vi /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.1.44 centos62.webhostinggeeks-dev3.com

Step 3: Configuring Main Squid Configuration File

After configuring the server hosts file, the next step is to configure the main Squid configuration file. This can also be done using the vi editor. The command to edit the Squid configuration file is:

[root@centos62 ~]# vi /etc/squid/squid.conf

Step 4: Adding Internal Network Name

In the Squid configuration file, you need to add your internal network name into the IP networks list where browsing should be allowed. For example, if your internal network name is webhostinggeeks-dev3.com, you would add the following lines:

acl localnet src 10.0.0.0/8             # RFC1918 possible internal network
acl localnet src 172.16.0.0/12          # RFC1918 possible internal network
acl localnet src 192.168.0.0/16.        # RFC1918 possible internal network
acl localnet src fc00::/7               # RFC 4193 local private network range
acl localnet src fe80::/10              # RFC 4291 link-local (directly plugged) machines
acl webhostinggeeks-dev3.com src 192.168.1.0/24    # Your internal network

Step 5: Allowing Browsing for Your Network

Next, you need to allow browsing for your network in the ACLsection. This can be done by adding the following lines to the Squid configuration file:

#http_access allow localnet
http_access allow localhost
http_access allow webhostinggeeks-dev3.com

Step 6: Configuring Squid Proxy Port

By default, Squid listens to port 3128. However, you can change this to any available port. To do this, make sure the Squid proxy port line is uncommented and set to your desired port. For example:

# Squid normally listens to port 3128
http_port 3128

Step 7: Configuring Auto Start at Boot for Squid Service

To ensure that the Squid service starts automatically at boot, you can use the following command:

[root@centos62 ~]# chkconfig squid on

Step 8: Starting Squid Service

After all the configurations are done, you can start the Squid service using the following command:

[root@centos62 ~]# service squid restart
[root@centos62 ~]# service squid restart
Stopping squid: ................                           [  OK  ]
Starting squid: .                                          [  OK  ]

Step 9: Configuring Client Browser

Finally, you need to configure your client browser to use the Squid proxy server. The specific steps for this will vary depending on the browser you are using.

proxy-centos6.2

Commands Mentioned

  • yum install squid -y – Installs Squid proxy server
  • vi /etc/hosts – Opens the server hosts file for editing
  • vi /etc/squid/squid.conf – Opens the Squid configuration file for editing
  • chkconfig squid on – Configures Squid to start automatically at boot
  • service squid restart – Starts or restarts the Squid service

Conclusion

Installing and configuring a Squid Proxy Server on CentOS 6.2 is a multi-step process that involves installing the Squid proxy, configuring the server hosts file, configuring the Squid configuration file, and setting up the client browser.

By following the steps outlined in this tutorial, you can successfully set up a Squid Proxy Server and enhance the performance of your web server.

Whether you’re using a dedicated server, a VPS server, or cloud hosting, understanding how to install and configure a Squid Proxy Server is a valuable skill for any webmaster or website administrator.

FAQ

  1. What is the role of a Squid Proxy Server?

    A Squid Proxy Server primarily acts as a caching proxy server between the user and the web, enhancing performance and reducing bandwidth usage. It can also function as a content accelerator or reverse proxy, serving cached versions of pages to fulfill requests.

  2. How do you install Squid Proxy Server on CentOS 6.2?

    You can install Squid Proxy Server on CentOS 6.2 using the yum command. The command is ‘yum install squid -y’.

  3. How do you configure the Squid Proxy Server?

    You can configure the Squid Proxy Server by editing the Squid configuration file.You can open this file for editing using the command ‘vi /etc/squid/squid.conf’. In this file, you can add your internal network name to the list of IP networks where browsing should be allowed, allow browsing for your network in the ACL section, and set the Squid proxy port.

  4. How do you start the Squid service?

    You can start the Squid service using the command ‘service squid restart’. This command will also restart the Squid service if it is already running.

  5. How do you configure your client browser to use the Squid proxy server?

    The specific steps to configure your client browser to use the Squid proxy server will vary depending on the browser you are using. Generally, you will need to go to the browser’s settings or preferences, find the section for network or proxy settings, and enter the IP address and port of the Squid proxy server.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *