About Linux FAQ

Browse More FAQs:

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

Posted by Vivek on Saturday January 6, 07 @12:31 pm

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)

Subscribe to our free e-mail newsletter or RSS feed to get all updates. You can Email this page to a friend.

Related Linux / UNIX FAQ:

Discussion on This FAQ

  1. AJ Says:

    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. AG's Blog Says:

    links for 2007-01-12…

    Squid content filtering: Block / download of music MP3, mpg, mpeg, exec files | Frequently Asked Questions The ultimate proxy. If you’re looking for a complete solution, tailored for large deployments(K12 or thinclients), try DansGuardian or Squidgua…

  3. Je pense, donc je suis libre » Archive du blog » Liens en vrac du 16-01-2007 Says:

    [...] Squid content filtering [...]

  4. Bhavik Says:

    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]

  5. Ricardo Martins » Blog Archive » Squid filtrando conteúdo Says:

    [...] [ link ] Converter em pdf. [...]

  6. Nandkishor Says:

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

  7. Kubitsch Says:

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

    david

  8. Zahid Iqbal Says:

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

  9. Omer Says:

    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.

  10. saravanaprakash Says:

    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

  11. dasappan Says:

    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

  12. amin Says:

    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

  13. slimetoner@yahoo.com Says:

    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 ?

  14. chzia Says:

    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.

  15. becci Says:

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

  16. sankar Says:

    please help me

    restric the download option in proxy linux server

  17. regex_warrior Says:

    That won’t stop me from doing

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

  18. shankar Says:

    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.

  19. Cru3L Says:

    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.

  20. ammaro Says:

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

Leave a Reply

We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Please do not use the comment form to ask for help / question. Ask your question on the excellent Linux tech support forum. Thank you very much for stopping by our site!

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

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

~ Last updated on: January 6, 2007

Copyright © 2006-2008 nixCraft. All rights reserved - TOS/Disclaimer - Privacy policy - Sitemap - Powered by Open source software.