LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-05-2011, 05:20 AM   #1
bryanmuts2000
LQ Newbie
 
Registered: Sep 2011
Posts: 8

Rep: Reputation: Disabled
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.
 
Old 10-05-2011, 08:10 AM   #2
deep27ak
Senior Member
 
Registered: Aug 2011
Location: Bangalore, India
Distribution: rhel 5x,6.0,6.2, centOS 5x,6.0,6.2
Posts: 1,194
Blog Entries: 4

Rep: Reputation: 221Reputation: 221Reputation: 221
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

Last edited by deep27ak; 10-05-2011 at 08:56 AM.
 
1 members found this post helpful.
Old 10-05-2011, 08:50 AM   #3
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 11,520

Rep: Reputation: 1502Reputation: 1502Reputation: 1502Reputation: 1502Reputation: 1502Reputation: 1502Reputation: 1502Reputation: 1502Reputation: 1502Reputation: 1502Reputation: 1502
@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

Last edited by bathory; 10-05-2011 at 09:11 AM.
 
Old 10-05-2011, 08:55 AM   #4
deep27ak
Senior Member
 
Registered: Aug 2011
Location: Bangalore, India
Distribution: rhel 5x,6.0,6.2, centOS 5x,6.0,6.2
Posts: 1,194
Blog Entries: 4

Rep: Reputation: 221Reputation: 221Reputation: 221
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
 
1 members found this post helpful.
Old 10-05-2011, 10:11 AM   #5
bryanmuts2000
LQ Newbie
 
Registered: Sep 2011
Posts: 8

Original Poster
Rep: Reputation: Disabled
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.

Last edited by bryanmuts2000; 10-05-2011 at 10:14 AM.
 
Old 10-05-2011, 10:15 AM   #6
deep27ak
Senior Member
 
Registered: Aug 2011
Location: Bangalore, India
Distribution: rhel 5x,6.0,6.2, centOS 5x,6.0,6.2
Posts: 1,194
Blog Entries: 4

Rep: Reputation: 221Reputation: 221Reputation: 221
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??
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Chrome to block downloads of hazardous .exe files LXer Syndicated Linux News 0 04-07-2011 02:50 AM
How to allow squid proxy downloads from a specific IP domain Vimuth *BSD 1 05-17-2010 03:17 PM
squid stop downloads nkutty Linux - Server 5 06-11-2008 10:25 PM
Preventing file downloads with Squid soumalya Linux - Security 4 11-23-2007 03:53 AM
Squid limited to 3 concurrent downloads lukebeales Linux - Software 0 06-14-2004 01:40 PM


All times are GMT -5. The time now is 11:00 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration