Squid deny users accessing a website

Q. How do I deny a user accessing particular website? For example block foo.com.

A. 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.

Want to read Linux tips and tricks, but don't have time to check our blog everyday? Subscribe to our daily email newsletter to make sure you don't miss a single tip/tricks. Subscribe to our weekly newsletter here!

{ 1 trackback }

HackITLinux
01.07.07 at 11:34 pm

{ 11 comments… read them below or add one }

1 Maroon 01.22.07 at 8:46 am

it’s out of subject! but related to SQuid.

I need to know what is the best filesystem compatilbe with storeio? to get the best perfomance ever…

one more questions about refresh_pattern anyone explain more to me about it…

any help would be highly appreciated

this squid is for caching onlu purpose and I’m looking to fine-tune it to get the best caching server ever.. thank you

2 Tek Bahadur Limbu 02.19.07 at 8:40 am

If you would like to experiment on Squid, the best file storage system for Squid would be COSS in my opinion. I am currently using ufs, aufs, diskd and coss in my squid servers. You have to compile Squid with the following options to enable all the storage systems: –enable-storeio=coss,ufs diskd null aufs

Please see the great Squid FAQ at: http://wiki.squid-cache.org/SquidFaq/

The default refresh-pattern should be good enough for almost any system:

refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern . 0 20% 4320

However if your needs are very specific, please see the default squid.conf for further details.

Have a nice day !!

3 elvis 03.02.07 at 8:45 am

hi,
i setup squid on a win2003 server os.fine i got it working but my challenge now is getting it to do web filtering to restrict access to certain sites. my research on this brought me to this site and i have tried the methods described here with no success.pls can any one help me out with this? u could send ur reply to my email: uwa45@yahoo.com. if neccessary a squid conf file wld be appreciated so that i can cross check with what i did.
Thanks for all ur help and support.

4 size limitetion for attachment 07.14.07 at 7:50 am

hi,
I setup the squid in linux intigration of windows. we are useing more then 20 users every thinking is working fine, but i think due to trafic squid is working only a day after it is dead. i want to improve the stability (mean i want to do fine fuining)

and i what restrict the users while attching file size to 1M maximem.

pls do the needful

5 kulpreet 08.02.07 at 7:48 am

Qiestion: How to configure sarg and squidGuard for squid servers to improve performance ?

6 Jv 01.29.08 at 12:34 pm

What r the solution for many no. of sites/domain blocking using above method?

7 Nandkishor 04.10.08 at 9:47 am

I have setup the transperant squid proxy to block some downloading & some urls.
How to block or deny the online listening musics & videows. Like for url youtube.com

Any Idea.

Cheers,
Nandkihosr

8 sreekumar 05.16.08 at 12:04 pm

how can i block a website in a particlar syatem or IP through squid

9 jonayed 07.26.08 at 10:03 am

Hi all,
I using squid as firewall. I want to block teamviewer which uses port 80 i guess.but i have to keep the 80 port open for browsing purpose. i am not that good at linux.
Can any one please help.

Thanks in advance
Jonayed
bangladesh

10 vijay 10.22.08 at 10:36 am

Hi Vivek,
I have configure squid in my office using your earlier artical of making transperent proxy. I want to block some site, for that I have use this artical but its not working. Please help.

Vijay

11 Arunraj 12.30.08 at 5:31 am

Hi friend,
Can u help me to “cache a particular website and store it in local system and if the client user send a request for that particular site, the proxy first check it in local cache,if not available means pass the request to internet” this is my requirement how to configure this by using squid proxy.

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Previous post: Linux Disable / Remove The Iptables Firewall

Next post: Change the From: email address in PHP mail()