• Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us
TecAdmin
Menu
  • Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us

How to Install and Configure Squid Proxy on Debian Linux

Written by Rahul, Updated on June 4, 2019

Squid is the most popular Proxy server for Unix like operating systems. It also used for web filtering. Its widely used for increasing web server speed by caching repeated data.

This tutorial helps you to install Squid proxy server on your Debian 9 Stretch system. Also provide basic configuration details of the Proxy server to allow traffic, restrict specific websites with keyword or domain names.

Step 1 – Install Squid on Debian

Login to your Debian 9 system using root or sudo privileges user. Then run the following commands on the console to install Squid on Debian 9 system from the default package repository.

sudo apt update
sudo apt install squid

Step 2 – Configure Squid Port

Squid default runs on port 3128. It is your choice to keep running squid on default port or change it to some different port. To change port edit squid configuration file and changehttp_port value.

/etc/squid/squid.conf

http_port 3128

After making changing let’s restart Squid service to reload the configuration changes

sudo service squid restart

Step 3 – Allow All Traffic

Sometimes you are required to allow all traffic on your proxy server. In Squid server open Squid configuration file. Comment the http_access deny all line and add the http_access allow all entry this file.

 http_access allow all
 #http_access deny all

Squid allow all

Step 4 – Block Specific Website with Squid

Let’s start with the additional configuration like blocking any website using squid proxy server. Add below rules to block specific website before any allow all rules. Below example will block yahoo.com and www.rediff.com.

acl blocksite1 dstdomain yahoo.com
acl blocksite2 dstdomain www.rediff.com
http_access deny blocksite1
http_access deny blocksite2

If you have a long list of domain names, Create a file /etc/squid/blockwebsites.lst and put domain names one per line and add below rule in the squid configuration file.

acl blocksitelist dstdomain "/etc/squid/blockwebsites.lst"
http_access deny blocksitelist

blockwebsites.lst file content example:

cat /etc/squid/blockwebsites.lst

yahoo.com
www.rediff.com

Step 5 – Block Specific Keyword with Squid

Add below rules to block specific website before any allow all rules. Below example will block all pages having keyword yahoo or Gmail.

acl blockkeyword1 url_regex yahoo
acl blockkeyword2 url_regex gmail
http_access deny blockkeyword1
http_access deny blockkeyword2

If you have a long list of keywords, Create a file /etc/squid/blockkeywords.lst and put keywords one per line and add below rule in the squid configuration file.

acl blockkeywordlist url_regex "/etc/squid/blockkeywords.lst"
http_access deny blockkeywordlist

blockkeywords.lst file content example:

cat /etc/squid/blockkeywords.lst

yahoo
gmail
facebook

Congratulation’s you have successfully install and configured Squid proxy server. Read next article to Configure Squid for Mac Address Based Filtering.

Share it!
Share on Facebook
Share on Twitter
Share on LinkedIn
Share on Reddit
Share on Tumblr
Share on Whatsapp
Rahul
Rahul
Connect on Facebook Connect on Twitter

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

1 Comment

  1. Avatar mohammadfa Reply
    September 14, 2019 at 5:27 am

    Thanks It was really helpful

Leave a Reply Cancel reply

Popular Posts

  • How to Install Python 3.9 on CentOS/RHEL 7 & Fedora 32/31 0
  • How To Install VNC Server on Ubuntu 20.04 1
  • How To Install NVM on macOS with Homebrew 0
  • (Solved) apt-add-repository command not found – Ubuntu & Debian 0
  • How to Install .NET Core on Debian 10 0
© 2013-2020 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy