Squid Deny Users Accessing a Website

How do I deny a user accessing particular website? For example deny access to a website called foo.com.

Squid cache is a popular open source web proxy server and web cache software.

It has a wide variety of uses, from speeding up a web server by caching repeated requests, to caching web, DNS and other network lookups for a group of people sharing network resources, to aiding security by filtering traffic.

Squid has powerful ACL (access control list). The primary use of the acl system is to implement simple access control.

How to deny a user from accessing particular site?

To block site called foo.com you need to add following two lines to your squid configuration file.
# vi /etc/squid/squid.conf

Search for `Access Controls’ and append following two lines:
acl blocksites dstdomain .foo.com
http_access deny blocksites

Save and close the file. Restart Squid:
# /etc/init.d/squid restart

Let us say you would like to deny access for anyone who browses to a URL with the word “bar” in it. Append following ACL:
acl blockregexurl url_regex -i bar
http_access deny blockregexurl

Save and close the file.

🥺 Was this helpful? Please add a comment to show your appreciation or feedback.

nixCrat Tux Pixel Penguin
Hi! 🤠
I'm Vivek Gite, and I write about Linux, macOS, Unix, IT, programming, infosec, and open source. Subscribe to my RSS feed or email newsletter for updates.

27 comments… add one
  • Sony AK May 13, 2011 @ 4:05

    what about URL like this? http://www.google.com/accounts can?

  • DFR Sep 15, 2011 @ 19:42

    Can someone help me here? I was trying to block some website using squid, it works… it blocked the sites i listed to be blocked, but it also blocked a system we are using it open the web site but the system does not work, it uses java.

  • Ambicapathy Oct 3, 2011 @ 15:09

    Can someone help me in blocking miniclip.com games sites. I tried different ways and none was working. Still users are able to access the site.

    Please help me with this.

  • Deepak Agrawal Oct 17, 2011 @ 10:05

    How to deny a particular user from accessing particular site?

    • Isurinda Jayawardana Nov 5, 2011 @ 5:03

      You can use netbios name of that user’s computer and block sites

      here is a sample config

      === squid.conf ===
      acl BLOCK_USER_FROM_NETBIOS srcdomain “/etc/squid/BLOCK_USER_FROM_NETBIOS”
      acl BLOCKED_URLS_FOR_SPECIFIC_USER dstdomain “/etc/squid/BLOCKED_URLS”
      Create a file : BLOCK_USER_FROM_NETBIOS in /etc/squid/ ( I suppose your squid configuration directory is /etc/squid)
      add your user’s computer name there. as an example, lets say computer name is “deepak” and your local domain name is “example.org” suppose your computer is a domain member of example.org. so the netbios name will be “deepak.example.org” , add that to your BLOCK_USER_FROM_NETBIOS file.

      after that create a file /etc/squid/BLOCKED_URLS
      and add urls you need to block. suppose you need to block facebook.com, add a line like this .facebook.com

      reload your configurations
      #squid -k reconfigure
      or restart the service.

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre> for code samples. Your comment will appear only after approval by the site admin.