LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Using Squid to block downloads (https://www.linuxquestions.org/questions/linux-newbie-8/using-squid-to-block-downloads-906506/)

bryanmuts2000 10-05-2011 04:20 AM

Using Squid to block downloads
 
Can someone tell me how I can use squid to block downloads by certain file types and/or by download size.

I want to block people from downloading files of certain type e.g .mp3 and also files of sizes above 30MB.

deep27ak 10-05-2011 07:10 AM

To block from downloading you will have to mention the extension name in the given format

create a file in the given location

Code:

#cd /etc/squid

#vi block-page.acl
\.[Exe][Xx][Ee]$
\.[Mm][Pp]3$


now open the configuration file

Code:

#vi /etc/squid/squid.conf
# INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
acl blockpages url_regex "/etc/squid/block-page.acl"
http_access deny blockpages

and if you want to block downloads of heavy files then
in the squid.conf lookout for
Code:

#Default:
# reply_body_max_size 0 allow all

just uncomment and rewrite with the following syntax
Code:

reply_body_max_size 30MB

bathory 10-05-2011 07:50 AM

@deep27ak
You've made an error in your regex. You need backslashes "\" and not "/". So this
Quote:

#vi block-page.acl
./[Exe][Xx][Ee]$
./[Mm][Pp]3$
should be:
Code:

#vi block-page.acl
\.[Exe][Xx][Ee]$
\.[Mm][Pp]3$

Other than that you're right.

@OP
Do as deep27ak says with the small correction of the regex above

Regards

deep27ak 10-05-2011 07:55 AM

oops m extremely sorry

I guess I was somewhere else while replying


Code:

\.[Ee][Xx][Ee]$
\.[Mm][Pp]3$

This is the syntax....thnx bathory

bryanmuts2000 10-05-2011 09:11 AM

O.k I've already tried this one but apparently whilst it prohibits downloads from the web browsers my understanding is that this won't stop downloading using the save target as and also the download managers. I am yet to test the save target as... or the download manager will update you when I have.

Oh by the way using the -i option better than the [Ee][Xx][Ee] option.

deep27ak 10-05-2011 09:15 AM

Well I personally checked them in my firefox and it was working well and good

Which browser are you using

and is it working with the browser default downloads??


All times are GMT -5. The time now is 12:22 PM.