Monday, January 6, 2014

How to Configure Squid proxy Server

Hello... Friends , Today we are going to discus about the Squid proxy server, If we Discus why the Squid proxy then let's see about it's features as :

  1. we can restrict to access any specific web sites
  2. we can restrict to access specific keywords 
  3. we can restrict any ipaddress to access our web site
  4. we can allow full access to specific ipaddress 
  5. we can restrict downloading size 
  6. we can configure squid proxy as a transparent proxy 
So we can say we can use squid proxy server for caching and filtering web content. various organisations and internet providers are using it to reduce the bandwidth and increase the response time.
Squid proxy service will cache the requested web-content and re-using it for the further request of the same web contents.

Squid proxy
configuration file : /etc/squid/squid.conf
Default port : 3128


Installation of squid proxy server 

Step 1 : install the squid proxy with yum server as 
# yum install squid



after installation start the squid proxy server as 
# service squid start
# chkconfig squid on

Basically the configuration file for squid proxy server is as /etc/squid/squid.conf . if we are using squid proxy without any change in it will work proper with squid caching feature too.

Step 2 : Now we need to setup our web browser to access internet through proxy server on port 3128.
we are using firefox so the proxy configuration for squid proxy will be as :
go to options /Preferences >> Advanced >> Network >> Settings >>Choose manual proxy configuration >>type your proxy server ip and port no.

by default the squid proxy server is working on port 3128 but we need to change it to 8080  & give the ipaddress as well & check to all. :')
Now open any website like here i am opening www.google.com & now check the log files                      # cat /var/log/squid/access.log 
in the image given bellow the request to the google.com is coming from proxy web server as we set my proxy server ip is 192.1168.56.103.


if we check it more clearly how a proxy server work check the image below 

in this image we can see the request done to the ISP is filtered by proxy server & after that this response to collected from the proxy server too.

Note : if you are not be able to send request using proxy server then disable your iptables & SELINUX from enforcing to disable as

# service iptables stop
# chkconfig iptables off
&
# SELINUX= enforcing to SELINUX= disable 

Now reboot your server :")

Now Let's Configure Squid proxy server as web filter :

as i tell you we can restrict any website in network or we can restrict any particular ipaddress using squid proxy server 

1. How to restrict any website 
we can block any particular website in our network like google.com , facebook.com etc. 
just open the conf file & edit it (vim /etc/squid/squid.conf ) as shown


try to open the restricted urls in your browser


2. How to restrict to access specific keywords 
these all if we want to restrict few sites if we have a long list then how to block them :')
just create a file in the /etc/squid directory example vim /etc/squid/restrictsites & add it in acl list 
as :
acl restrictsites url_regex -i "/etc/squid/restrictsites"
http_access deny restrictsites


 let's try with browser can we access these words or not


3. How to restrict ip address :
this is same as blocking urls for ip address blocking we just need to add acl as 

acl restricted_client src ip_address

for complete network add as 

acl restricted_client_network src ip_address/gateway


No comments:

Post a Comment