LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
LinkBack Search this Thread
Old 07-28-2009, 09:42 AM   #1
allancth
Member
 
Registered: Mar 2009
Posts: 36

Rep: Reputation: 15
Squid Blocking Domain (but not in search engine)


I can block sites. In my ACL file, let's say I have blocked

.youtube.com
.*sex.*
.*game.*
...
...
...

However when I do a google search for the word sex, it is blocked as well. I do not want the search to be blocked and I would like it to display the search result but if I visit the link www.sex.com, it will be blocked.

Can this be done in regular expression?
 
Old 07-28-2009, 03:17 PM   #2
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Debian, FreeBSD
Posts: 3,755
Blog Entries: 5

Rep: Reputation: Disabled
To explicitly deny access to a site, I'd recommend using the ACL element dstdomain rather than putting together a regular expression.

(My guess is you're already using a regular expression that is set up incorrectly. It would help if you posted your ruleset, BTW.)
 
Old 07-28-2009, 05:29 PM   #3
allancth
Member
 
Registered: Mar 2009
Posts: 36

Original Poster
Rep: Reputation: 15
Hello. This the rules currently configured:-


acl all src 0.0.0.0/0.0.0.0
acl manager proto cache_object
acl localhost src 127.0.0.1/255.255.255.255
acl to_localhost dst 127.0.0.0/8
acl password proxy_auth REQUIRED

# webconfig: acl_start
acl webconfig_lan src x.x.x.x/24
acl webconfig_to_lan dst x.x.x.x/24
# webconfig: acl_end

acl privoxy dstdomain config.privoxy.org

# does not block the following ports
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 563 # https, snews
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 280 # http-mgmt
acl Safe_ports port 488 # gss-http
acl Safe_ports port 591 # filemaker
acl Safe_ports port 81 82 83 10000 # Web-based administration tools
acl Safe_ports port 777 # multiling http
acl Safe_ports port 1863 5050 # MSN and Yahoo Messenger

# flash & shockwave
acl deny_rep_mime_flashvideo rep_mime_type -i video/flv
acl deny_rep_mime_shockwave rep_mime_type -i ^application/x-shockwave-flash$

# site, files and advertisements
acl block-site url_regex "/etc/squid/squid-block-site.acl"
acl block-url-ads url_regex -i "/etc/squid/squid-banner-ads.acl"
acl blockfiles urlpath_regex -i "/etc/squid/squid-block-file.acl"

# video & audio streaming
acl StreamingRequest1 req_mime_type -i ^video/x-ms-asf$
acl StreamingRequest2 req_mime_type -i ^application/vnd.ms.wms-hdr.asfv1$
acl StreamingRequest3 req_mime_type -i ^application/x-mms-framed$
acl StreamingRequest4 req_mime_type -i ^audio/x-pn-realaudio$
acl StreamingReply1 rep_mime_type -i ^video/x-ms-asf$
acl StreamingReply2 rep_mime_type -i ^application/vnd.ms.wms-hdr.asfv1$
acl StreamingReply3 rep_mime_type -i ^application/x-mms-framed$
acl StreamingReply4 rep_mime_type -i ^audio/x-pn-realaudio$
acl CONNECT method CONNECT

# Only allow cachemgr access from localhost
http_access allow manager localhost
http_access deny manager

# Deny requests to unknown ports
http_access deny !Safe_ports

# Deny CONNECT to other than SSL ports
http_access deny CONNECT !SSL_ports

http_access deny blockfiles
http_access deny block-site
http_access deny block-url-ads

http_access deny StreamingRequest1 all
http_access deny StreamingRequest2 all
http_access deny StreamingRequest3 all
http_access deny StreamingRequest4 all
http_reply_access deny StreamingReply1 all
http_reply_access deny StreamingReply2 all
http_reply_access deny StreamingReply3 all
http_reply_access deny StreamingReply4 all

# deny all other access to this proxy
http_access deny privoxy
http_access allow localhost password
http_access allow webconfig_lan password
http_access deny all

http_reply_access deny deny_rep_mime_flashvideo
http_reply_access deny deny_rep_mime_shockwave
http_reply_access allow all

In squid-block-site.acl, I have these regex:-

\.metacafe.com
\.youtube\.com
\.porntube\.com
\.xtube\.com
\.xnxx\.com
\.rapidshare\.com
\.9adultsexgames\.com
movies.yahoo.com
video.google.com
urs.microsoft.com
.*game.*
.*sex.*

The search result will be blocked when I search for game or sex. Please advice. Thank you.
 
Old 07-28-2009, 05:48 PM   #4
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Debian, FreeBSD
Posts: 3,755
Blog Entries: 5

Rep: Reputation: Disabled
I think I understand what you're doing. It sounds like you just want to match the server name, and not any part of the GET request. Substitute your rule for:
Code:
acl block-site dstdom_regex "/etc/squid/squid-block-site.acl"
 
Old 07-28-2009, 05:59 PM   #5
allancth
Member
 
Registered: Mar 2009
Posts: 36

Original Poster
Rep: Reputation: 15
Yes! I tried to use dstdomain and then I realized that wow... this will be painful to block the sites one by one. Thank you.
 
Old 07-29-2009, 06:07 AM   #6
chitambira
Member
 
Registered: Oct 2008
Location: Fife
Distribution: RHEL, Centos
Posts: 373
Blog Entries: 1

Rep: Reputation: 48
anomie is not saying you should use dstdomain. Infact he said use dstdom_regex and with this, squid will match words like 'sex' in the url only and NOT in search engine. you should read carefully all the help that is offered to you here. Hope this clarifies it.
 
1 members found this post helpful.
Old 07-14-2010, 11:41 AM   #7
jma89
LQ Newbie
 
Registered: Jan 2010
Location: Earth
Distribution: Ubuntu
Posts: 5

Rep: Reputation: 0
Part of your problem is that you aren't escaping the periods in those last few lines of your ACL.

Regular expressions don't use the asterisk for a wild card, the use the period. So you would want something like this:

Code:
\.[.]*sex[.]*\.[.]*
The [.]* says "block any character, any number of characters, 0 and up". Hence, the block you wanted.

I suggest checking out this site if you need to brush up on some regex stuff: http://www.regular-expressions.info/
 
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Squid+DansGuardian not working properly. squid blocking sites that should be linuxlover.chaitanya Linux - Server 12 12-19-2010 11:47 PM
SQUID for blocking yahoo and msn [inc squid.conf] chrisfirestar Linux - Security 10 03-03-2008 08:33 AM
new search engine? markhod General 3 04-08-2005 04:44 PM
search engine jean-michel LQ Suggestions & Feedback 2 04-09-2004 12:40 PM
Search Engine? phek Linux - General 1 09-20-2001 07:00 PM


All times are GMT -5. The time now is 05:07 PM.

Main Menu
 
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
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration