LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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
  Search this Thread
Old 04-08-2014, 07:15 PM   #1
zadowsmash
LQ Newbie
 
Registered: Oct 2012
Distribution: RHEL / SLES
Posts: 8

Rep: Reputation: Disabled
Squid - Unable to block sites


Hi LQ Community,

I am setting up a squid proxy for my organisation to replace Microsoft TMG.

The requirements are as follows:

* Must use a proxy pac file - Done
* Must authenticate via AD domain controllers - Done
* Ability to block websites - Experiencing issues.

Environment:

RHEL 6.5
Squid 3.1

I have read many guides on how to block sites and it seems simple enough but I just can't get it to work. No matter what I do it always allows all sites and doesn't block anything. Ultimately, I want to block all sites and only allow what is in the file /etc/squid/black_white_lists/allowed-sites.txt

My /etc/squid/squid.conf is below:

Code:
# Recommended minimum configuration:
#
#
# Authentication
auth_param ntlm program /usr/bin/ntlm_auth --helper-protocol=squid-2.5-ntlmssp
auth_param ntlm children 10

acl auth proxy_auth REQUIRED
http_access allow auth

#
acl manager proto cache_object
acl localhost src 127.0.0.1/32 ::1
acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 ::1

# Example rule allowing access from your local networks.
# Adapt to list your (internal) IP networks from where browsing
# should be allowed
acl localnet src 10.0.0.0/8     # RFC1918 possible internal network
acl localnet src 172.16.0.0/12  # RFC1918 possible internal network
acl localnet src 192.168.0.0/16 # RFC1918 possible internal network
acl localnet src fc00::/7       # RFC 4193 local private network range
acl localnet src fe80::/10      # RFC 4291 link-local (directly plugged) machines

acl SSL_ports port 443
acl Safe_ports port 80          # http
acl Safe_ports port 21          # ftp
acl Safe_ports port 443         # https
acl Safe_ports port 70          # gopher
acl Safe_ports port 210         # wais
acl Safe_ports port 1025-65535  # unregistered ports
acl Safe_ports port 280         # http-mgmt
acl Safe_ports port 488         # gss-http
acl Safe_ports port 591         # filemaker
acl Safe_ports port 777         # multiling http
acl CONNECT method CONNECT

acl allowed_sites url_regex "/etc/squid/black_white_lists/allowed-sites.txt"
http_access allow allowed_sites

#
# Recommended minimum Access Permission configuration:
#
# Only allow cachemgr access from localhost
http_access allow manager localhost
http_access deny manager

# Deny requests to certain unsafe ports
http_access deny !Safe_ports

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

# We strongly recommend the following be uncommented to protect innocent
# web applications running on the proxy server who think the only
# one who can access services on "localhost" is a local user
#http_access deny to_localhost

#
# INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
#

# Example rule allowing access from your local networks.
# Adapt localnet in the ACL section to list your (internal) IP networks
# from where browsing should be allowed
http_access allow localnet
http_access allow localhost

# And finally deny all other access to this proxy
http_access deny all

# Squid normally listens to port 3128
http_port 8080

# We recommend you to use at least the following line.
hierarchy_stoplist cgi-bin ?

# Uncomment and adjust the following to add a disk cache directory.
#cache_dir ufs /var/spool/squid 100 16 256

# Leave coredumps in the first cache dir
coredump_dir /var/spool/squid

# Add any of your own refresh_pattern entries above these.
refresh_pattern ^ftp:           1440    20%     10080
refresh_pattern ^gopher:        1440    0%      1440
refresh_pattern -i (/cgi-bin/|\?) 0     0%      0
refresh_pattern .               0       20%     4320
Contents of /etc/squid/black_white_lists/allowed-sites.txt (this is just for testing so far. Our current white list will be migrated once I get this working)

Code:
.access.redhat.com
.vmware.com
.mcafee.com
If anyone could shed some light on my problem it would be much appreciated.

Cheers.
 
Old 04-08-2014, 07:46 PM   #2
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 3,340

Rep: Reputation: Disabled
Quote:
Originally Posted by zadowsmash View Post
Code:
acl allowed_sites url_regex "/etc/squid/black_white_lists/allowed-sites.txt"
You refer to this ACL further down, but you also have a rule saying http_access allow localnet before the "deny all" rule. Since the "localnet" ACL only contains a source address match, won't that allow any system on the local network to access any site?

To debug why Squid ACLs aren't doing what you want them to do, add a debug statement to the squid.conf and restart Squid. There'll be an entry in the log for every request that's matched against an ACL.

Quote:
Originally Posted by zadowsmash View Post
Contents of /etc/squid/black_white_lists/allowed-sites.txt (this is just for testing so far. Our current white list will be migrated once I get this working)

Code:
.access.redhat.com
.vmware.com
.mcafee.com
While not related to the problem you're having, I'd just like to point out that the above lines aren't regular expressions. Well, technically they are, but they won't just match the literal strings .access.redhat.com and so on, which I assume is what you want.
 
Old 04-08-2014, 07:58 PM   #3
zadowsmash
LQ Newbie
 
Registered: Oct 2012
Distribution: RHEL / SLES
Posts: 8

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Ser Olmy View Post
To debug why Squid ACLs aren't doing what you want them to do, add a debug statement to the squid.conf and restart Squid. There'll be an entry in the log for every request that's matched against an ACL.
Thanks ill add the debug options and see if I can nut it out.

Cheers.
 
Old 04-09-2014, 11:35 PM   #4
zadowsmash
LQ Newbie
 
Registered: Oct 2012
Distribution: RHEL / SLES
Posts: 8

Original Poster
Rep: Reputation: Disabled
Figured out what the issue was.

I needed to place

Code:
http_access allow auth
Underneath

Code:
http_access allow allowed_sites
All is now working as expected.

Cheers.
 
  


Reply



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
Squid to block all the sites except 1 or 2 sites winxandlinx Linux - Networking 8 10-27-2010 02:53 AM
squid 2.6 not blocking sites even i entered ACL to block sites mohantorvalds Linux - Server 1 01-08-2009 04:17 AM
How To Block Sites Using Squid In Linux saha.sandipan Linux - Networking 3 11-04-2007 04:00 PM
Squid block sites linuxnirmal Linux - Security 5 11-15-2006 10:59 AM
how to block sites with squid.conf boakiba Linux - Networking 1 08-11-2003 05:45 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 04:53 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
Open Source Consulting | Domain Registration