Facebook Twitter Instagram
    TecAdmin
    • Home
    • Ubuntu 20.04
      • Upgrade Ubuntu
      • Install Java
      • Install Node.js
      • Install Docker
      • Install LAMP Stack
    • Tutorials
      • AWS
      • Shell Scripting
      • Docker
      • Git
      • MongoDB
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    Home»Network Services»Proxy»How to Setup Squid Proxy Server on Ubuntu 18.04 & 16.04

    How to Setup Squid Proxy Server on Ubuntu 18.04 & 16.04

    RahulBy RahulNovember 20, 20183 Mins ReadUpdated:November 29, 2018

    Squid is the most popular Proxy server for Unix like operating systems. It also used for the web filtering. Squid also useful as caching proxy server for the HTTP, HTTPS, FTP protocols.

    This article will help you to setup Squid Proxy Server on Ubuntu 18.10, 18.04 LTS, 16.04 LTS, and 14.04 LTS systems.

    Step 1 – Install Package

    Squid packages are available in default yum repositories. Execute below command on your server to install SQUID proxy server.

    sudo apt update
    sudo apt install squid
    

    Step 2 – Configure Squid Port

    The default port for the Squid proxy servers is 3128. You can change this as per the requirements. To setup Squid on different port, Edit squid configuration file and change http_port value with new port.

    /etc/squid/squid.conf
     http_port 3128
    

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

    sudo service squid restart
    

    The next steps will help you to Setup Squid Proxy Server on Ubuntu systems. Use only those settings, which is required for your proxy server.

    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.

    /etc/squid/squid.conf
     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.

    /etc/squid/squid.conf
    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.

    /etc/squid/squid.conf
    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.

    /etc/squid/squid.conf
    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.

    /etc/squid/squid.conf
    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.

    proxy proxy server setup squid squid Ubuntu
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp
    Previous ArticleHow To Install FFmpeg on Debian 9 (Stretch)
    Next Article How To Install Erlang on Fedora 35/34/33

    Related Posts

    Change Screen Resolution of An Ubuntu VM in Hyper-V

    Updated:May 2, 20222 Mins Read

    Download Ubuntu 22.04 – DVD ISO Images

    Updated:May 7, 20222 Mins Read

    Ubuntu 22.04 – Release Schedule & Features

    Updated:February 25, 20222 Mins Read

    Top 5 Most Stable Linux Distributions in 2022

    Updated:January 11, 20226 Mins Read

    How To Install and Secure MongoDB on Ubuntu 20.04

    Updated:September 7, 20214 Mins Read

    How To Install Anaconda on Ubuntu 20.04

    Updated:September 5, 20213 Mins Read

    10 Comments

    1. Raja Danyal on July 19, 2019 7:45 am

      how to set ip range of whole network that are using net to allow specific website and deny block_bad website

      Reply
    2. Zak on July 3, 2019 1:19 pm

      Good Article!

      Just a question to the tecadmin.net, how can i use multiple (additional) ip adresses for adittional proxies. I got some additional IP’s from my provider, but I don’t know how to set them up? Can you help tecadmin?

      Thanks & Regards,
      Alex

      Reply
    3. david on July 1, 2019 9:20 am

      I have done everything you said –
      the guide is very simple and clear –
      I got till the end and setup like you said , but now what?
      when I try to enter localhost:3128 – I get nothing
      where is the web gui?
      also how can I see it’s working?
      I try to setup in my router proxy serve – but it’s not working
      the comuter is 10.0.0.100 in my network – what do I need to do now?
      can you explain what to do now?
      Thanks ,

      Reply
    4. Hemanta Baruah on June 8, 2019 6:05 pm

      Open squid conf file as a root user…..
      sudo vi /etc/squid/squid.conf

      Reply
    5. Anup Shetty on March 6, 2019 11:03 am

      How to get the access.log file in a readable format to generate Squid Proxy Reports

      Reply
      • mor on February 17, 2020 7:51 pm

        awk ‘{a[$3]++} END {for(i in a) print i}’ /var/log/squid/access.log

        Reply
    6. Bobak Tooyserkani on March 6, 2019 1:34 am

      I’m having trouble with Step 2, as the squid.conf file is [Read-Only] and it won’t allow me to overwrite it with my http_port number. What should I do?

      Reply
      • Rahul on March 6, 2019 4:17 am

        This might be a permission issue. Try setting proper permission and save file with “:wq!” in vim editor.

        Reply
    7. rownak on January 27, 2019 9:55 am

      great article for online user.

      Reply
    8. ChrisL on December 16, 2018 1:03 am

      I am pulling my hair out. Everytime I check my IP (web running thu squid proxy) from a site like whatsmyip.org, I get a different IP address each time. I only want the public IP address of the squid proxy server to show.

      Reply

    Leave A Reply Cancel Reply

    Recent Posts
    • How to Enable / disable Firewall in Windows
    • How to Install JAVA on Ubuntu 22.04
    • Switching Display Manager in Ubuntu – GDM, LightDM & SDDM
    • Changing the Login Screen Background in Ubuntu 22.04 & 20.04
    • How To Install PHP (8.1, 7.4 or 5.6) on Ubuntu 22.04
    Facebook Twitter Instagram Pinterest
    © 2022 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.