APLawrence.com -  Resources for Unix and Linux Systems, Bloggers and the self-employed


© Tony Lawrence, aplawrence.com

squidGuard works with Squid to block access to sites by domain, ip address or even keywords. It is very flexible, even allowing you to block access at certain times of day and allow it at others, and even to define groups within your organization that have different access privileges.

This all works because Squid allows you to define a redirector program that gets to examine each requested web page before Squid goes and gets it. If the redirector decides to send you somewhere else, that's what happens.

I installed squidGuard on an E-Smith server. I used a partially packaged set of rpm's from http://netsourced.com/servers/docs/squidguard-howto.html. Complete directions for the installation are there.

However, although these rpm's appeared to install, it didn't work. Just a little bit of investigation showed that although everything was indeed installed correctly, the supplied conf file ( /usr/local/squidGuard/squidGuard.conf ) didn't quite match the distribution. A little editing fixed it, and a "squid -k reconfigure" started the squidGuard processes running.

Check that with "ps -e | grep squid"- you should see several squidGuard processes running. The number is controlled by the "redirect_children" entry in the squidlog.conf (remember that on E-Smith this file gets created by scripts in /etc/e-smith/templates - the rpm's take care of that for you).

I also needed to adjust the redirect cgi (this is the page that people get redirected to when their access is blocked by squidGuard)- the rpm correctly installs it in the primary/cgi-bin directory (where e-smith html files live), but the supplied conf file doesn't point there.

Here's the configuration file I used:

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

dest local {
        domainlist      local/domains

dest untrusted {
   urllist      untrusted/urls

dest porn {
   domainlist   porn/domains
   expressionlist       porn/expressions
   urllist      porn/urls

dest gambling {
   domainlist   gambling/domains
   urllist      gambling/urls

acl {
         default {
             pass  local !in-addr !untrusted !porn !gambling all
             redirect http://e-smith.customer.com/cgi-bin/blocked.cgi?clientaddr=%a&clientname=%n&clientuser=%i&clientgroup=%s&url=%u          }

Each "dest" entry refers to a directory in /usr/local/squidGuard/db. Each directory can have lists of domains, precise url's or expressions ( see squidGuard for details ) that will be blocked or passed. For example, the file "local/domains" just contains one line:

That's the local address of the internal web server. Normally, raw ip addreses are always blocked ( by the "!in-addr" in the "pass" section of the acl ), but we want to let the internal machine be accessed that way. The "local" database accomplishes that.

The "untrusted" database contains specific sites that this client wants to block:


The "porn" and "gambling" databases were supplied by the RPM's. Good examples of using expressions are found in the porn/expressions files; I'm not going to reproduce that here because it would cause this page to get indexed for searches I don't want it to show up in!

I tested with lynx by setting

export http_proxy

but you could of course also test from any client that is using the proxy. Keep in mind that if you are using NAT (the default on E-smith), any user that knows how to NOT use the proxy can just bypass all this entirely.

Also see http://www.mail-archive.com/devinfo%40lists.e-smith.org/msg04815.html


More Articles by

Find me on Google+

Tony Lawrence

Click here to add your comments
- no registration needed!

Tue Dec 9 12:47:17 2008: 4886   anonymous

Could you help me out?
I'm trying to integrate squidguard with LDAP, but since CN has white space in between, squidguard is going into emergency mode.

Tue Dec 9 14:13:04 2008: 4888   TonyLawrence

Did you try quoting the spaces with "\"'s or URL escaping them (%20) ?

Don't miss responses! Subscribe to Comments by RSS or by Email

Click here to add your comments

If you want a picture to show with your comment, go get a Gravatar
Kerio Connect Mailserver

Kerio Samepage

Kerio Control Firewall

Have you tried Searching this site?

Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more.

Contact us

Jump to Comments

Many of the products and books I review are things I purchased for my own use. Some were given to me specifically for the purpose of reviewing them. I resell or can earn commissions from the sale of some of these items. Links within these pages may be affiliate links that pay me for referring you to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain. I also may own stock in companies mentioned here. If you have any question, please do feel free to contact me.

I am a Kerio reseller. Articles here related to Kerio products reflect my honest opinion, but I do have an obvious interest in selling those products also.

Specific links that take you to pages that allow you to purchase the item I reviewed are very likely to pay me a commission. Many of the books I review were given to me by the publishers specifically for the purpose of writing a review. These gifts and referral fees do not affect my opinions; I often give bad reviews anyway.

We use Google third-party advertising companies to serve ads when you visit our website. These companies may use information (not including your name, address, email address, or telephone number) about your visits to this and other websites in order to provide advertisements about goods and services of interest to you. If you would like more information about this practice and to know your choices about not having this information used by these companies, click here.

This post tagged: