Wednesday, September 3, 2014

CentOS/RedHat : Install and configure transparent squid proxy server : RHEL/CentOS 6.x

Install and configure transparent squid proxy server : RHEL/CentOS 6.x

In this tutorial,we will learn about how to install and configure transparent squid proxy server on RHEL/CentOS 6.x .In this practical,we will install Squid version 3.5.0 package in CentOS 6.5 / RHEL 6.5 .Squid server are designed to run in Unix like operating system. Up to version 2.7, Windows Operating System was supportive. Till the date of writing this post, no Windows Operating System supportive port has been developed in Squid version 3.x .

What is Squid Server

Squid is a web cache and web filtering server.It is based upon Harvest Cache Daemon.
Because Squid server has ability to do cacheing, it helps in improving the performance of web access. It can deliver the web content either static,dynamic or streaming way.It helps to speed up web browsing to its end clients.

Default port number use by Squid service

By-defualt port number 3128 is used by squid service

Squid : Transparent Web Proxy Server

Squid Server widely used for Web filtering and cacheing. It is also used as Transparent Web Proxy Server. Transparent Proxy is also known as Interception Caching.
Interception Caching is a process when a HTTP request from client ends redirected to Cache Server(Squid) without doing any configuration in end user clients. By this way,end user clients do not know the traffic has been redirected to cache server(Transparent Proxy)

Transparent Squid Proxy versus Ordinary Squid proxy

In Ordinary Squid Proxy Server, the end user client traffic is redirected to Squid proxy server but for this , we have to configure the web browser settings in each client machine.(We will also show,how to do settings in this tutorial)
In Transparent Squid Proxy, we do not have to do settings in web browser of each client machine.The traffic can be easily redirected to Squid Server. IPTABLES for NAT (Network Address Translation),play very crucial role to setup the Transparent Squid Proxy.(always remember this)
Squid Proxy Server

Install and Configure Squid Transparent Proxy Server

Follow the given below steps to install and configure the Squid Web Proxy Server.
Step 1: Create a yum client repo file in RHEL/CentOS. This step we are doing ,to get the latest Squid version.
Paste given below contents in file /etc/yum.repos.d/squid.repo
Step 2: Install EPEL repository in system (For getting Perl packages)
Step 3: By using yum command install Squid and perl-Crypt-OpenSSL
Below given is reference.It shows the packages which will be installed on using command yum install squid perl-Crypt-OpenSSL
Step 4: After installing squid package, all squid related configuration files will be located at /etc/squid .Explore these files
Step 5:Take the backup of squid.conf file.
Step 5: Disable the SELINUX . Edit the file /etc/sysconfig/selinux and change the value of SELINUX=disabled
Now restart the system so that SELINUX can take effect permanently.
IMPORTANT NOTE : In case , you want to use SELINUX in ENFORCING mode, read this post .(You may have to use the same steps more than one times because of avc denial in SELINUX policy for Squid)
Step 6: Below given is default squid.conf file configuration settings.(You can use same settings for Ordinary Squid Proxy Server)
NOTE : egrep -v '^#|^$' will hide the lines starting with # and all blank lines.
Step 7: To make Squid Proxy Server as Transparent Proxy Server. Add “accel vhost allow-direct” with line“http_port 3128″ in /etc/squid/squid.conf file .
As per our network, we are using 172.16.0.0/255.255.0.0 inside LAN .Hence we will edit squid.conf file atacl localnet src
Now I will add the new local network acl line in squid.conf file and comment acl lines related to other local network(10.0.0.0/8 ,172.16.0.0/12, 192.168.0.0/16)
Below given is complete configuration for Squid Transparent Proxy Server
Step 8 : Restart the Squid service
Step 9 : Create a IPTABLES script . You can modify the script as per your requirement. (Test the script in staging machine before applying it to live server)
Create bash script file
Paste below given contents in file /root/firewall.sh. Save and close the file after this
Step 10 : Give execute permission to /root/firewall.sh and only to owner that is root
Step 11 : Execute the firewall.sh script

Client Side Configuration

Step 12: At client side,you do not have to configure Web browser.
The only requirement is, the IP Subnet of client should be allowed in Squid Proxy Server

No comments: