# SquidGuard not filtering



## vikkymoorthy (Dec 3, 2013)

Hi friends,

I'm new here, please bear with me if I asked anything silly.

I'm trying to configure a Squid proxy with SquidGuardian. *W*hen *I* test it I get the following response. 


```
echo "http://www.playboy.com/ - squid GET -" | /usr/local/bin/squidGuard -c /usr/local/squidGuard/squidGuard.conf -d

2013-12-03 15:37:58 [2669] New setting: dbhome: /usr/local/squidGuard/db
2013-12-03 15:37:58 [2669] New setting: logdir: /usr/local/squidGuard/log
2013-12-03 15:37:58 [2669] init domainlist /usr/local/squidGuard/db/adult/domains
2013-12-03 15:37:58 [2669] loading dbfile /usr/local/squidGuard/db/adult/domains.db
2013-12-03 15:37:58 [2669] init urllist /usr/local/squidGuard/db/adult/urls
2013-12-03 15:37:58 [2669] loading dbfile /usr/local/squidGuard/db/adult/urls.db
2013-12-03 15:37:58 [2669] squidGuard 1.4 started (1386065278.395)
2013-12-03 15:37:58 [2669] squidGuard ready for requests (1386065278.396)
2013-12-03 15:37:58 [2669] source not found
2013-12-03 15:37:58 [2669] no ACL matching source, using default
http://google.com -/- squid GET
2013-12-03 15:37:58 [2669] squidGuard stopped (1386065278.397)
```

Earlier, the file permission was wrong so I was getting an error in /var/log/squid/cache.log like 
	
	



```
db_open: Permission denied
```

*W*hen I restart the squid service, I'm getting the following logs in cache.log:


```
2013/12/03 15:42:19| Preparing for shutdown after 222 requests
2013/12/03 15:42:19| Waiting 30 seconds for active connections to finish
2013/12/03 15:42:19| FD 21 Closing HTTP connection
2013/12/03 15:42:50| Shutting down...
2013/12/03 15:42:50| basic/auth_basic.cc(97) done: Basic authentication Shutdown.
2013/12/03 15:42:50| Closing unlinkd pipe on FD 23
2013/12/03 15:42:50| storeDirWriteCleanLogs: Starting...
2013/12/03 15:42:50|   Finished.  Wrote 0 entries.
2013/12/03 15:42:50|   Took 0.00 seconds (  0.00 entries/sec).
CPU Usage: 0.402 seconds = 0.221 user + 0.181 sys
Maximum Resident Size: 49616 KB
Page faults with physical i/o: 0
Memory usage for squid via mallinfo():
        total space in arena:    5404 KB
        Ordinary blocks:         5119 KB    440 blks
        Small blocks:               0 KB      7 blks
        Holding blocks:          1096 KB      4 blks
        Free Small blocks:          0 KB
        Free Ordinary blocks:     284 KB
        Total in use:            6215 KB 115%
        Total free:               284 KB 5%
2013/12/03 15:42:50| Open FD UNSTARTED     8 DNS Socket IPv6
2013/12/03 15:42:50| Open FD READ/WRITE    9 DNS Socket IPv4
2013/12/03 15:42:50| Open FD UNSTARTED    10 squidGuard #1
2013/12/03 15:42:50| Open FD READ/WRITE   11 Waiting for next request
2013/12/03 15:42:50| Open FD UNSTARTED    12 squidGuard #2
2013/12/03 15:42:50| Open FD UNSTARTED    14 squidGuard #3
2013/12/03 15:42:50| Open FD UNSTARTED    16 squidGuard #4
2013/12/03 15:42:50| Open FD UNSTARTED    18 squidGuard #5
2013/12/03 15:42:50| Squid Cache (Version 3.1.10): Exiting normally.
2013/12/03 15:42:51| Starting Squid Cache version 3.1.10 for x86_64-redhat-linux-gnu...
2013/12/03 15:42:51| Process ID 2719
2013/12/03 15:42:51| With 1024 file descriptors available
2013/12/03 15:42:51| Initializing IP Cache...
2013/12/03 15:42:51| DNS Socket created at [::], FD 7
2013/12/03 15:42:51| DNS Socket created at 0.0.0.0, FD 8
2013/12/03 15:42:51| Adding nameserver 10.77.134.1 from /etc/resolv.conf
2013/12/03 15:42:51| Adding nameserver 202.144.66.6 from /etc/resolv.conf
2013/12/03 15:42:51| Adding nameserver 202.144.66.6 from /etc/resolv.conf
2013/12/03 15:42:51| helperOpenServers: Starting 5/5 'squidGuard' processes
2013/12/03 15:42:51| User-Agent logging is disabled.
2013/12/03 15:42:51| Referer logging is disabled.
2013/12/03 15:42:51| Unlinkd pipe opened on FD 23
2013/12/03 15:42:51| Local cache digest enabled; rebuild/rewrite every 3600/3600 sec
2013/12/03 15:42:51| Store logging disabled
2013/12/03 15:42:51| Swap maxSize 0 + 262144 KB, estimated 20164 objects
2013/12/03 15:42:51| Target number of buckets: 1008
2013/12/03 15:42:51| Using 8192 Store buckets
2013/12/03 15:42:51| Max Mem  size: 262144 KB
2013/12/03 15:42:51| Max Swap size: 0 KB
2013/12/03 15:42:51| Using Least Load store dir selection
2013/12/03 15:42:51| Set Current Directory to /var/spool/squid
2013/12/03 15:42:51| Loaded Icons.
2013/12/03 15:42:51| Accepting  HTTP connections at [::]:3128, FD 24.
2013/12/03 15:42:51| HTCP Disabled.
2013/12/03 15:42:51| Squid plugin modules loaded: 0
2013/12/03 15:42:51| Adaptation support is off.
2013/12/03 15:42:51| Ready to serve requests.
2013/12/03 15:42:52| storeLateRelease: released 0 objects
```


```
tail -F /usr/local/squidGuard/log/squidGuard.log

2013-12-03 15:42:51 [2724] squidGuard 1.4 started (1386065571.251)
2013-12-03 15:42:51 [2724] squidGuard ready for requests (1386065571.252)
2013-12-03 15:42:51 [2725] New setting: dbhome: /usr/local/squidGuard/db
2013-12-03 15:42:51 [2725] New setting: logdir: /usr/local/squidGuard/log
2013-12-03 15:42:51 [2725] init domainlist /usr/local/squidGuard/db/adult/domains
2013-12-03 15:42:51 [2725] loading dbfile /usr/local/squidGuard/db/adult/domains.db
2013-12-03 15:42:51 [2725] init urllist /usr/local/squidGuard/db/adult/urls
2013-12-03 15:42:51 [2725] loading dbfile /usr/local/squidGuard/db/adult/urls.db
2013-12-03 15:42:51 [2725] squidGuard 1.4 started (1386065571.254)
2013-12-03 15:42:51 [2725] squidGuard ready for requests (1386065571.255)
```


```
/usr/local/squidGuard/SquidGuard.conf

dbhome /usr/local/squidGuard/db
logdir /usr/local/squidGuard/log

dest adult {
  domainlist adult/domains
  urllist adult/urls
}

acl {
  default {
    pass !adult none
    redirect http://google.com
  }
}
```


```
/etc/squid/squid.conf

#
# Recommended minimum configuration:
#
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 my_net src 10.77.134.2-10.77.134.254
#no_cache deny QUERY
#
# Recommended minimum Access Permission configuration:
#
# Only allow cachemgr access from localhost
http_access allow my_net
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
visible_hostname squid1.minglebox.com
#
# 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

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

# Squid normally listens to port 3128
http_port 3128

# 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
cache_effective_user squid
cache_effective_group squid
# Leave coredumps in the first cache dir
coredump_dir /var/spool/squid

url_rewrite_program /usr/local/bin/squidGuard -c /usr/local/squidGuard/squidGuard.conf
url_rewrite_children 5
url_rewrite_access allow localhost
# 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
```


----------



## ShelLuser (Dec 3, 2013)

First of all FreeBSD is not Linux. So being new to a Linux environment really has no meaning here because although FreeBSD has some similarities these only apply to the commandline environment. The rest is quite different.

I'm afraid I don't quite understand the problem. Because your first SquidGuard session shows an error but in the logfile it appears as if everything is working normally. Which makes me wonder if that test you tried was actually valid.

Another thing; in your squidguard.conf file you say to have the following contents:


```
dbhome /usr/local/squidGuard/db
logdir /usr/local/squidGuard/log

dest adult {
domainlist adult/domains
urllist adult/urls
}

acl {
default {
pass !adult none
redirect http://google.com
}
}
```
If you take a closer look at the pass statement you'll see that it doesn't seem to pass anything. You reject the adult ACL but then also tell it to pass none, so basically nothing. Shouldn't this say something like:


```
pass !adult all
```


----------



## vikkymoorthy (Dec 3, 2013)

Thanks for your quick response. I modified squidGuard.conf, but it's still not working. Please let me know, what details should I provide for you to have a better understanding of this issue?


```
dbhome /usr/local/squidGuard/db
logdir /usr/local/squidGuard/log

dest adult {
  domainlist adult/domains
  urllist adult/urls
}

acl {
  default {
    pass !adult all
    redirect http://google.com
  }
}
```


```
echo "http://www.playboy.com/ - squid GET -" | /usr/local/bin/squidGuard -c /usr/local/squidGuard/squidGuard.conf -d[/i]
2013-12-03 16:50:25 [2990] New setting: dbhome: /usr/local/squidGuard/db
2013-12-03 16:50:25 [2990] New setting: logdir: /usr/local/squidGuard/log
2013-12-03 16:50:25 [2990] init domainlist /usr/local/squidGuard/db/adult/domains
2013-12-03 16:50:25 [2990] loading dbfile /usr/local/squidGuard/db/adult/domains.db
2013-12-03 16:50:25 [2990] init urllist /usr/local/squidGuard/db/adult/urls
2013-12-03 16:50:25 [2990] loading dbfile /usr/local/squidGuard/db/adult/urls.db
2013-12-03 16:50:25 [2990] squidGuard 1.4 started (1386069625.526)
2013-12-03 16:50:25 [2990] squidGuard ready for requests (1386069625.527)
2013-12-03 16:50:25 [2990] source not found
2013-12-03 16:50:25 [2990] no ACL matching source, using default
http://google.com -/- squid GET
2013-12-03 16:50:25 [2990] squidGuard stopped (1386069625.528)

[root@squid1 ~]# tail -F /usr/local/squidGuard/log/squidGuard.log
2013-12-03 16:40:56 [2967] squidGuard 1.4 started (1386069056.658)
2013-12-03 16:40:56 [2967] squidGuard ready for requests (1386069056.659)
2013-12-03 16:40:56 [2968] New setting: dbhome: /usr/local/squidGuard/db
2013-12-03 16:40:56 [2968] New setting: logdir: /usr/local/squidGuard/log
2013-12-03 16:40:56 [2968] init domainlist /usr/local/squidGuard/db/adult/domains
2013-12-03 16:40:56 [2968] loading dbfile /usr/local/squidGuard/db/adult/domains.db
2013-12-03 16:40:56 [2968] init urllist /usr/local/squidGuard/db/adult/urls
2013-12-03 16:40:56 [2968] loading dbfile /usr/local/squidGuard/db/adult/urls.db
2013-12-03 16:40:56 [2968] squidGuard 1.4 started (1386069056.663)
2013-12-03 16:40:56 [2968] squidGuard ready for requests (1386069056.664)
```


----------



## vikkymoorthy (Dec 4, 2013)

Any help on this please?


----------

