Squid content filtering: Block / download of music MP3, mpg, mpeg, exec files

by Vivek Gite · 50 comments

Q. For security and to save bandwidth I would like to configure Squid proxy server such way that I do not want my users to download all of the following files:
MP3
MPEG
MPG
AVG
AVI
EXE

How do I configure squid content filtering?

A. You can use squid ACL (access control list) to block all these files easily.

How do I block music files using squid content filtering ACL?

First open squid.conf file /etc/squid/squid.conf:

# vi /etc/squid/squid.conf
Now add following lines to your squid ACL section:

acl blockfiles urlpath_regex "/etc/squid/blocks.files.acl"
You want display custom error message when a file is blocked:
# Deny all blocked extension
deny_info ERR_BLOCKED_FILES blockfiles
http_access deny blockfiles

Save and close the file.

Create custom error message HTML file called ERR_BLOCKED_FILES in /etc/squid/error/ directory or /usr/share/squid/errors/English directory.
# vi ERR_BLOCKED_FILES
Append following content:

<HTML>
<HEAD>
<TITLE>ERROR: Blocked file content</TITLE>
</HEAD>
<BODY>
<H1>File is blocked due to new IT policy</H1>
<p>Please contact helpdesk for more information:</p>
Phone: 555-12435 (ext 44)<br>
Email: helpdesk@yourcorp.com<br>

Caution: Do not include HTML close tags </HTML> </BODY> as it will be closed by squid.
Now create /etc/squid/blocks.files.acl file:
# vi /etc/squid/blocks.files.acl
Append following text:
\.[Ee][Xx][Ee]$
\.[Aa][Vv][Ii]$
\.[Mm][Pp][Gg]$
\.[Mm][Pp][Ee][Gg]$
\.[Mm][Pp]3$

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

Squid in action:

Squid content filtering howto
(Click to enlarge)

Featured Articles:

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!

{ 3 trackbacks }

AG's Blog
01.12.07 at 7:29 am
Je pense, donc je suis libre » Archive du blog » Liens en vrac du 16-01-2007
01.16.07 at 10:32 am
Ricardo Martins » Blog Archive » Squid filtrando conteúdo
03.17.07 at 4:41 am

{ 47 comments… read them below or add one }

1 AJ 01.09.07 at 1:01 pm

I use squid but all my filterings is done via dansguardian. Bannerfilter is great to stop adverts. And web custome written based admin console keeps my non un*x admins happy

2 Bhavik 03.07.07 at 3:18 pm

In Squid, i want to do the routing through users?
eg. user-a, user-b if user a can access internet then data transer through 246kbps line & if user-b access internet then it’s data transer through 1mbps line.
[note:- user-a & user-b can set any where, any pc in network]

3 Nandkishor 04.03.07 at 10:24 am

Hi,
I do the following configuration in squid but it is not possible to block the downloads.
Plz give me the solution for this

4 Kubitsch 04.11.07 at 2:50 pm

Hello, thanks, but it dosnt work for me…no effect.

david

5 Zahid Iqbal 04.12.07 at 10:28 am

In squid how I can block files for a particular IP or user

6 Omer 06.18.07 at 10:43 am

it worked for me , but it seems that still users are able to download files dont know how.
how i can totally block the download from users.
if u have downloading agent, then it by-pass and start download.
How can i make it strong so that no one can download any thing through any software.

7 saravanaprakash 08.02.07 at 11:13 am

Hi ,
i was config my proxy successfully. But i can’t access my outlook. i think its prots are blocked.
Then how can i unlock my outlook ports…
If anybody konw the solution, Please Immediately send to me… my NAT server ip was given to the gateway of my proxy server and proxy server gateway was given to the users gateway.. Its correct or not ..
If u know any other way….. please share with me…

I want the correct solution immediately…

MY personal EMAIL ID is saravanaprakasht@yahoo.com

8 dasappan 08.08.07 at 9:44 am

my office is blocked to down load mp3 files. Can you please help me how to down load mp3 files.

Your favourable reply will be highly appreciated.

Thanks in advance

Das

9 amin 08.10.07 at 3:53 am

Dear Sir,

I have followed your step-by-step instruction to block download files.

i succesfully manage to block the files while clicking selected files. and i received error msg from squid.

Unfortunately i still manage to download that file by simply using “Save Link As..” menu as i right click the mouse.

it seem like users still manage to download prohibited file as configured in squid by using right click menu.

please advice.

regards

amin

10 slimetoner@yahoo.com 11.11.07 at 11:25 am

Help!

What if i want to…
replace “Men at work” with “Aliens at party”

Is this possible ?
Can i do this in squid without using any addons ?

11 chzia 11.14.07 at 10:24 am

This did not work at all. It is not blocking downloads. Yes one thing was possible that downloading by right clik and save target was stoped, rest all downloads are working. Not a good solution. Pls advise for another.

12 becci 11.16.07 at 9:34 am

is there away to unblock bebo cuz are school is gay and has filtered ALL the proxy sites to date
thanks becci

13 sankar 12.14.07 at 3:56 am

please help me

restric the download option in proxy linux server

14 regex_warrior 02.29.08 at 6:57 pm

That won’t stop me from doing

GET http://www.example.com/foo.mp3?parameter=bogus

15 shankar 03.04.08 at 2:15 pm

Hai friends pls help me in this

I our Company we have 200 system and one linux server i want to configure squid in a way that no body should download files in my network and 2 to 3 system i should give premision to download can any body help me plzzzzzzzzzz.

16 Cru3L 04.29.08 at 12:57 am

Is it possible to block downloads from yahoo mail and other web based email in Squid? I can block downloads using the instructions above but it can only block direct download from a site.

17 ammaro 05.13.08 at 11:55 am

our admin blocked all media files if anybody can help me break his policy,,,

18 Rico 05.13.08 at 6:12 pm

The blocking file list can be simpler by adding “-i” to the blockfiles statement in squid.conf, that is:
acl blockfiles urlpath_regex -i “/etc/squid/blocks.files.acl”

# and in
# /etc/squid/blocks.files.acl
.exe$
.avi$
.mpg$
.mpeg$
.mp33$

19 Rico 05.13.08 at 6:29 pm

shankar, you can do it like this:
in your squid.conf

acl special_grp src “/etc/squid/special_grp”
acl blocked_files url_regex -i “/etc/squid/blocked_files


http_access allow special_grp blocked_files
http_access deny !special_grp blocked_files


# make sure the above lines are above the line “http_access allow our_networks”

in your /etc/squid/special_grp enter the ips of the systems (one ip per line) that you allow to download and in your /etc/squid/block_files enter the following content
\.exe$
\.avi$
\.mpg$
\.mpeg$
\.mp3$

Then reload squid and you are all set.

20 ASP Consultant 06.23.08 at 8:02 am

it’s done by easy step like
acl downloadfiles urlpath_regex -i “/etc/squid/downloadfiles.acl”

http_access deny downloadfiles

21 Rashid Shafique 08.08.08 at 4:14 pm

i want me to download mp3 of my choice but it is blocked.it just saves the file as HTML document rather than mp3 format how i can get rid of it.i use the intrnet provided by LAN of my company.

22 Amani Makota 08.27.08 at 8:31 am

Hi
This is my first time to enter in to this forum.

I want to block users to more than 5MB per day.How can I do so.
I am using Lunix Fedora

Regargs

23 venkat 01.31.09 at 11:05 am

Hi everone,I had configure squid proxy server still it’s working but i need restrict to downloads for users can u help.already i am doing like.acl blickfile urlpath _ regix -i “/etc/squid/blocks.filies.acl”
http_access deny blockfiles
deny_info ERR_BLOCKED_FILES blockfiles acl
iam creating file block.files.acl under squid
mention all extention on that file like \.exe$
after restarting the sevice
but .exe file will downloaded . Can you help where exact problem found.

Thanks
venkat

24 Rico 02.17.09 at 2:01 am

The method described in this post can be easily passed if user appends a single question mark or to supply some information that is not required, see it yourself:
http://example.com/file.exe?
or
http://example.com/file..exe?name=test

25 varun 03.12.09 at 8:07 pm

Hello, I have hostel Boys downloard movies I dont want. how can i block all downloarding. we are providing wi-fi. if i block my server is that ok for all ??? please reply very urgent at varunmalik1985@hotmail.com

26 Khalil Mir 04.17.09 at 4:21 am

Dear All,
I have done above procedure & it is working good, but there is a problem,
It also blocked symantec live update, Kindly help me for allow symantec live update with these reistrictions.
Thankx

27 kamal sen 04.22.09 at 12:07 pm

sir I want to configure the squid proxy server file in such a way that it contains one public IP and two private IP (EX 192.168.0.1 172.16.0.1 ) and and block various sites (I.E orkut.com , blocl exe file download etc) but in some ip there is no rule ; please tell me how can i configure that proxy server .

28 V.Balaviswanathan 05.04.09 at 1:17 pm

Please help me configure

Sir,in my company we have two gateways and need to give access only to few selected people in my office. and they need to configure through squid. Please help me… Can anyone help me. If so i would be thankful to them

Bala

29 ishtiaq 05.29.09 at 12:10 pm

Is this possibe that if a network/IP not allowed in squid try to come through his/her browser ( by using the squid IP in the browser) then his/her browser should display a message ( you are not allowed to come throught this proxy or any other message)

Waiting .

Regards,
Ishtiaq Ahmed

30 Sheikh Amjad Zia 06.16.09 at 2:13 pm

Hi
Dear
i am usind squid in linux for proxy server i want to block the downloading , music file of all types of extensions image file for user side please guide mein this regard. & also i want to block chatting all kinds of messangers.

31 SHEIKH AMJAD ZIA 06.18.09 at 7:27 am

Dear
how are you i am facing a problem regarding blocking of unwanted sites in my network using squid please help me in this regards. i want to block all kinds of messangers, chat sites musical sites & all other voulger sites. i am waiting for your quick response.

Thanks

Amjad Shaikh

32 V.Balaviswanathan 06.18.09 at 8:20 am

@ Amjad

Hi , you need to create the acl for that I wll give you the syntax for that

under acl tag write like this
acl block url_regex “/etc/squid/squid-block.acl”
and under http_access block
http_access allow manager should be changed to http_access allow all
http_access deny block
and create a seperate file squid-block.acl and list out those unwanted sites and then reload the squid.
Make sure that ur internet connection is made through proxy

Regarding messanger and chat sites you need to use iptables

33 ajeet 07.01.09 at 8:30 am

how to block porn website using squid server

34 ajeet 07.01.09 at 8:33 am

how to block websites

35 kiranjith 09.01.09 at 9:33 am

Hi
could some one please guide me that how to integrate the squid with Active directory to filter/ schedule the access to web based on the usernames (From Active directory)

36 Kamran Rashid Khan 10.28.09 at 5:58 am

Hi,
How can i blcok Gpass,Freegate & UltraSurf using Fedora 11 Squid Proxy.

37 rajen 11.13.09 at 12:43 pm

we have got wi-fi by college but we are unable to download any videoes or we can’t even see pictures.so suggest us..

38 Usman Arif 12.30.09 at 10:38 am

hi how r u .would u like to tell where we place this lines please
can u send code with example

http_access allow special_grp blocked_files
http_access deny !special_grp blocked_files

39 Usman Arif 12.30.09 at 10:40 am

i block downloading on fedora 11.now i want to allow some ip to download and watch online movie
how can i make white class of these ip

plz inform with example

40 kushal rajpurohit 12.31.09 at 9:50 am

Dear Sir,

I have followed your step-by-step instruction to block download files.

i succesfully manage to block the files while clicking selected files. and i received error msg from squid.

Unfortunately i still manage to download that file by simply using “Save Link As..” menu as i right click the mouse.

it seem like users still manage to download prohibited file as configured in squid by using right click menu.

please advice.

regards
kushal

41 rocaboy1uk 01.27.10 at 11:15 am

Vivek,

Is this the route one would take to create a music download service? By that I mean, if a user has not paid for certain music, they can be restricted from downloading a particular track or album, however if they have paid they are granted access. Also, if it is a shared environment with access only to a DB such as MySQL and a scripting language such as PHP, how would this be possible?

42 Vivek Gite 01.27.10 at 12:09 pm

rocaboy1uk: No

43 Sheikh Amjad Zia 01.29.10 at 6:53 am

Dear
AOA
How are you, i hope that you are fine , on my MINUX Machine an error messgae is dispalyed when i start the machine please solve my problem on urgent bases the error message is as “Maximum Memory Performance is achieved with matched DIMMS. The Installed amountof memory in Channel A is not equal to the amount of press any key to continue”

i am waiting for your quick & positive reply.

Amjad Zia

44 Omer ijaz 02.01.10 at 10:34 pm

Hello,
I want to allow all sites accpect my live video streaming websits i.e youtube ,matacafe
how i can able to do that plz spourt me

Regarding
omer

45 khalil 02.04.10 at 1:19 pm

Dear Mr. Atul,
Can u help me , I want to access my apps server from internet (out side of my local area network). your help is highly thanfull.

khalil mir

46 Manish Chaudhary 02.06.10 at 8:11 am

hiiiiiiiii sir i want to block all porn website that can be access by user

Regarding

Manish Chaudhary

47 Ramin 02.09.10 at 7:45 am

how to deny that user cannot download with using dmaster.exe

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 FAQ:

Next FAQ:

nixCraft FAQ PDF Collection Now Available To All