Configure Squid Proxy Server


Proxy Server acts as an intermediate between your local network and Internet.
Proxy servers is used to watch the user’s internet activities, control the bandwidth and block various sites in large industries, or schools or colleges.

Every information sent by local machines goes to proxy server to the internet, and every incoming connection or data comes via Proxy server to a particular machine in the network.

How proxy works.

How proxy works.

So why install a proxy server?

  • Well, You can block certain social networking websites, or other websites you don’t want.
  • It gives a daily/weekly/monthly/yearly report of the usage of internet (Light squid).
  • It helps you monitor users on your network.
  • Blocks websites without valid certificated.
  • Proxy server helps you cache websites, thus providing them instantly.
  • Provides security to the network from Intrusions.
  • Since all connections and to and fro from proxy server, less chance of user’s machine being affected by Virus.

Now that we have a basic idea about What is Proxy server? and its advantages, lets see how to configure your own proxy server in any Linux Operating System. We will use Squid Proxy to install a proxy server and test its working.
So the steps to configure Squid proxy server are :

  1. yum install squid -y
    Install Squid if you don’t have it, and create a backup of the configuration file.
  2. vim /etc/squid/squid.conf
    Open the configuration file inside /etc/squid with your favorite editor.

    Open configuration file

    Open configuration file

  3. acl ‘hostname’ ‘IP/subnet’
    acl ‘label’ dstdomain ‘file path’
    Inside the configuration file,
    – In ‘acl’ section add
    ‘acl [your hostname] [your IPclass/subnet]. ‘Acl’ stands for the access list.
    – Below that if you need to block sites, create a label before ‘dstdomain’ (destination domain) and then write the path of the file which has the name of websites to be blocked.
    – In the local net section, just below ‘acl’ section,uncomment  the line containing your IP range. If you skip this step, you won’t be able to browse the internet.

    define access list, destination domain and local net.

    define access list, destination domain and local net.

  4.  http_access deny ‘label’
    Search for ‘deny requests’ and in that, add a line
    ‘http _access deny ‘label’
    – This will deny http access to the websites to the label name.
    – Since the label nameis associated with a file, whose path you have defined earlier, http access would be denied to all websites inside that file.

    deny http access to blocked sites.

    deny http access to blocked sites.

     

  5. http_access allow ‘hostname’
    – Search for http_access allow and add a line
    – http_access allow ‘your hostname’

    Allow http access for your hostname

    Allow http access for your hostname

     

  6. http_port 8080
    – Search for ‘http_port’. The default port of Squid proxy server is 3128. If you want to change it, edit it here.
    – Note: The same port number should be entered in your browser’s settings.

    changing default port name.

    changing default port name.

     

  7. Create file containing blocked websites.
    Go to the place you defined in ‘acl’ section for blocked websites. Create a file in that same place.

    Create an empty file for blocked websites.

    Create an empty file for blocked websites.

     

  8. Enter names of websites to be blocked.
    Enter the name of website you want to block inside that file. Save and quit.

    Enter the name of websites you need to block.

    Enter the name of websites you need to block.

     

  9. ifconfig
    – Check your IP address.

    Check IP

    Check IP

     

  10. Enter proxy settings in browser.
    Enter settings in browser.

    Enter settings in browser.

     

  11. Check your proxy server.

    Facebook Working.

    Facebook Working.

     

    Rediff working.

    Rediff working.

     

    Youtube is blocked.

    Youtube is blocked.

    Yahoo is also blocked

    Yahoo is also blocked

    Sub-domains of yahoo blocked.

    Sub-domains of yahoo blocked.


You can add ‘ visible hostname ‘hostname’ ‘ at the end of the configuration file, if you want squid to display your hostname.

For video tutorial check this video.

Leave a Reply