How to use squid to block websites

Written by meganferland
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to use squid to block websites
(Jupiterimages/Pixland/Getty Images)

Squid is an open source web proxy server and caching software. It has a variety of uses for speeding up access time by caching repeated requests, DNS lookups and other useful lookups that people on a shared network would need. Squid can be used to increase network security by filtering Internet traffic and blocking certain websites that are listed in a blocking policy or contain keywords in a blocking policy.

Skill level:


  1. 1

    Ensure that Squid is properly installed. Consult the documentation for your particular distribution and operating system if needed.

  2. 2

    Configure the Access Control List (ACL) in the Squid configuration file “squid.conf”. This file should be found in “etc./squid/”. Add the following lines to the configuration file:

    acl bad url_regex “/etc/squid/squid-block.acl” http_access deny bad

    Save changes to the squid.conf file.

  3. 3

    Enter the URLs and keywords you want to block in the newly created /etc/squid/squid-block.acl file. You can add partial or whole URLs and keywords that will block any pages where the keyword is found. Remember to describe the URLs you plan to block carefully, as you could inadvertently block desirable sites that contain the blocked URL description. Entering “.com” into the file will block every site ending in “.com”. Likewise, choose keywords carefully so that Squid does not block desirable sites that contain the keyword.


    These entries will cause the filter to block any URL that contains "" The filter will also block any site that contains the word "bored."

  4. 4

    Save changes to the squid-block.acl file.

  5. 5

    Create a squid-noblock.acl file to allow certain exceptions to the filtering rules to pass. Websites that contain URLs or words where keywords are part of the word will be blocked by the policy. Enter the URLs and keywords of sites not to block in this file.


    These entries will cause the URL "" to be allowed through the filter, even though it contains the blocked URL ""

  6. 6

    Save changes to the squid-noblock.acl file.

  7. 7

    Add the “no-block” rule to the squid.conf configuration file before the “block” rule in order to put the “no-blocking” rules into action:

    acl special_urls url_regex “/etc/squid/squid-noblock.acl” http_access allow admin_ips special_urls

    Save changes to the squid.conf file.

  8. 8

    Restart Squid in order for the new filtering policies to take effect.

Don't Miss

  • All types
  • Articles
  • Slideshows
  • Videos
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.