Block music/download through Squid

We might need to BLOCK certain types of files to be downloaded, like mp3/mpeg/avi/exe and other and display our customized error-message.

STEP #1 – vim /etc/squid/squid.conf — add these lines under your ACL section

acl   blockfiles   urlpath_regex   "/etc/squid/blocks.files.acl"
# Deny all blocked extension
deny_info ERR_BLOCKED_FILES blockfiles
http_access deny blockfiles

STEP #2 – Create rule file for blocking certain types of file.

vi /etc/squid/blocks.files.acl

\.[Ee][Xx][Ee]$
\.[Aa][Vv][Ii]$
\.[Mm][Pp][Gg]$
\.[Mm][Pp][Ee][Gg]$
\.[Mm][Pp]3$

STEP #3 – Create customized error file under /usr/share/squid/errors/English/ directory.

vi ERR_BLOCKED_FILES

<HTML>
<HEAD>
<TITLE>ERROR: Blocked file content</TITLE>
</HEAD> <BODY>
<H1>File is blocked due to our IT policy</H1>
<p>Please contact Network NUTS admin for more information:</p>

STEP #4 – Restart the squid service.

service squid restart; chkconfig squid on

God Bless.

Check more on linux at http://networknuts.net

Advertisements