DansGuardian 1.1.x Detailed Installation Guide

Fri 17th August 2001 - Draft 7

Contents



Overview

This is not a HOWTO. This document is my attempt at detailed installation instructions for DansGuardian. If you just want to get DansGuardian up and running as quickly as possible, you might want to read the brief installation guide.



Prerequisites

You must have a Linux box already running a fairly recent distribution. Redhat 6.2 or better will do perfectly. You also need to have squid running and configured with listening on port 3128.

DansGuardian is a filtering pass-through that sits between the client browser and the Squid proxy. It listens on port 8080 and connects to squid on port 3128. So you must have no other daemon running already using port 8080.

You will need a web server. Apache (httpd) that comes with RedHat 6.2 is absolutely perfect and you would be hard pushed to find a better web server. The server is used to display a cgi perl script that gives the user notification of an 'Access Denied'.

You will need the standard development tools installed such as glibc and make. The default Redhat 6.2 installation and most others come with these installed so you don't need to worry about them.

Most of the time during this work you will need to be logged on as root. A more experienced user will be able to determine when, however for most people - stay logged on as root for the entirety.

Make sure you have all of the above installed and working before you continue.



Collecting what you need

DansGuardian relies upon one supporting library to work; nb++ which provides daemon and other functionality. You will need to download it from here:
nb++ 0.6.0

And also, of course, you need DansGuardian! You can download it from here: DansGuardian



Installation and compilation

If you just want to quickly get on with the installation and avoid all this detail, don't forget you can simply follow the brief installation guide.

nb++ library

Untar the package by issuing a tar -zxpf nb++-0.6.0.tar.gz. This will create a subdirectory nb++-0.6.0. cd into this subdirectory and run ./configure, make, then make check, then make install, and if desired a make clean.

If you have problems or want more detailed instructions, read the INSTALL file within the nb++-0.6.0 directory.

DansGuardian

Ah - the meat! Untar the package by issuing a tar -zxpf dansguardian-*.tar.gz. This will create a subdirectory DansGuardian-*.*.*.

cd into this new directory. You may need to edit the Makefile. Infact pull it up into your favourite editor now so you know what we are talking about. The Makefile compiles all the components of DansGuardian and produces a binary file. It then copies all the files needed to where they need to be. I.e. the dansguardian binary, the configuration files, the SysV script and the perl script used for reporting denied pages. The final thing that it does is create and permission a log directory.

The binary file is copied into /usr/sbin/

The perl file is copied into /home/httpd/cgi-bin/

The configuration files are copied into /etc/dansguardian

The SysV script (the thing to allow you to stop and start the service in NT speak) is copied into /etc/rc.d/init.d/

The log directory is /var/log/dansguardian

If you really don't know or care about the Makefile settings then don't worry - just leave it as is - especially if you are using a Redhat 6.2 or better distribution.

If you know what you are doing then edit the Makefile to your liking. The installation structure uses a RedHat style which you may not like. However keep in mind the extra complications such as editing the SysV script to point to the new binary location etc.

When a page is denied, DansGuardian redirects to a cgi perl script on your web server to report to the user. This makes it easy to customise the message. This server does not need to be the same machine as the DansGuardian filter server, however if it is not local you will need to amend or comment out the perl script copying line in the Makefile.

Now do a make, make install and optional make clean. This will have installed DansGuardian, but you need to configure the server to start the daemon at bootup. To do this use your favourite SysV Init Editor such as linuxconf or the one that comes with KDE and Gnome. You ought to put it some number higher than squid and httpd but not much higher.

We need to configure the address of your web server that will display the access denied perl script. Pull /etc/dansguardian/dansguardian.conf into your favourite editor and edit the accessdeniedaddress. For more information see the Options section.

The last thing that we need to do is configure the log rotation. The idea of log rotation is to make sure that the filesystem does not get filled eventually with a huge log file. Most daemons that log such as httpd and squid rotate their logs once a week; the oldest log file is deleted and the 2nd oldest is renamed to log.4. The current log is renamed to log.1. The rest you can guess. The Makefile copies a log rotation script to the configuration directory. We need to run it once a week, so (as root) do a crontab -e and enter the following:

59 23 * * sun /etc/dansguardian/logrotation

Then save. This will schedule it for 23:59 every Sunday. Or configure as pleases you. You can edit the logrotation file if you want.

As linux is so stable, you are unlikely to ever need to reboot it (I have several with uptime since last millennium) and so DansGuardian will never be started. You can start and stop it manually by doing a: /etc/rc.d/init.d/dansguardian start (or stop).

DansGuardian is now installed and ready to go with the default settings. However you may wish to change some of these default settings...



Further customisation - configuration options

DansGuardian is highly configurable. The source code is provided so you have the ultimate in configurability. Most people will be content with modifying the configuration files though. (If you do modify the source code please send what you've done to Daniel).

After you have modified any configuration file, to apply the changes you will need to restart DansGuardian. To do this type the following in a terminal:

/etc/rc.d/init.d/dansguardian restart

There is one main configuration file, several banned lists and an exception list. These are all explained below:

exceptionsitelist

This contains a list of domain endings that if found at the end of the requested URL, DansGuardian will not filter the page. The domains should be specified in lower case and care should be exercised in not leaving trailing or leading spaces.

exceptioniplist

This contains a list of client ips who you want to bypass the filtering. For example, the network administrators computers ip who will want to be able to download any file and access any site.

bannedphraselist

This contains a list of banned phrases. The phrases must be enclosed between < and >. DansGuardian is supplied with an example list. You can not use phrases such as <sex> as this will block sites such as Middlesex University. The phrases can contain spaces. Use them to your advantage. This is the most useful part of DansGuardian and will catch more pages than PICS and squidGuard put together. Phrases must be given in lower case.

As of DansGuardian 0.8.7 you can also have combinations of phrases as well, which if they are all found in a page, it is blocked.

bannedmimetypelist

This contains a list of banned MIME-types. If a URL request returns a MIME-type that is in this list, DansGuardian will block it. DansGuardian comes with some example MIME-types to deny. This is a good way of blocking inappropriate movies for example. You are a fool if you ban the MIME-type text/html or image/*. The list must be in lower case.

bannedextensionlist

This contains a list of banned file extensions. If a URL ends in an extension that is in this list, DansGuardian will block it. DansGuardian comes with some example file extensions to deny. This is a good way of blocking kiddies from downloading those lovely screen savers and hacking tools. You are a fool if you ban the file extension .html, or .jpg etc. The list must be in lower case.

dansguardian.conf

Reporting settings

You can change the reporting level for when a page gets denied. It can say just 'Access Denied', report why and report why and what phrase. The latter may be more useful for testing, but the middler would be more useful in a school environment.

Network settings

These allow you to modify the ip address of the server running squid as well as the squid port and port that DansGuardian listens on. It is possible to configure the Access Denied reporting page here also.

Logging settings

It contains a logging setting which lets you reduce or increase the logging level. You can log nothing, just denied pages, text based and all requests. HTTPS requests only get logged when the logging is set to 3 - all requests.

Content Filtering settings

Here you can modify the location of the list files. Not recommended.

Phrase Scanning settings

Here you can choose normal or intelligent phrase scanning. Intelligent is just slightly slower, but is more likely to locate phrases by removing HTML and multiple white space characters.

PICS settings

These allow you to finely tune the PICS filtering. Each PICS section comes with a description of the allowed settings and what they represent. The default settings as provided with DansGuardian block everything even slightly unsuitable. Take a look at the dansguardian.conf file for more information on the different PICS ratings.

The only setting that is vitally important that you configure in the dansguardian.conf file is the accessdeniedaddress setting. You should set this to the address of your Apache server with the perl access denied reporting script. For most people this will be the same server as squid and DansGuardian. If you really want you can change this address to a normal html static page on any server.



Squid configuration

There is none that is required as DansGuardian appears to squid just as a normal web browser. However...

We need to make sure that squid will not allow client browsers to bypass DansGuardian. This is a non trivial problem. What I will assume is that you have already blocked open web access and the only way to access the web is through squid and hence DansGuardian. This goal is achievable in a number of ways.

squid.conf method

You can modify the acl rules so that only localhost has access. In my squid.conf I had the following lines:

# INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
#
acl localnet src 192.168.42.0/255.255.255.0
http_access allow localnet
http_access allow localhost
http_access deny all

So I remmed out both the localnet lines with a #. I believe that the default configuration of squid is to only have localhost allowed so you probably don't even have to do this.

With proxy authentication things get a little bit more complex. With no DansGuardian in my squid.conf I have:

authenticate_program /usr/bin/smb_auth -W DOMAIN -U 192.168.0.2
acl domainusers proxy_auth REQUIRED
http_access allow domainusers
http_access deny all
Which allows authenticated users to access the proxy from anywhere.

But when I installed DansGuardian I needed to allow SSL through without going through DansGuardian. I also needed to disallow people to bypass DansGuardian. So the same section became:

authenticate_program /usr/bin/smb_auth -W DOMAIN -U 192.168.0.2
acl domainusers proxy_auth REQUIRED
acl linuxserver src 192.168.0.1/255.255.255.255
acl ntserver src 192.168.0.2/255.255.255.255
http_access allow linuxserver
http_access allow ntserver
http_access allow domainusers localhost
http_access allow CONNECT SSL_ports
http_access deny all
So for all web access (ssl or not) the user is required to be authenticated, but SSL is allowed to bypass DansGuardian. I also allow the NT and linux servers to bypass the filtering and access squid directly.

ipchains method 1

You could redirect incoming requests on port 3128 from the local net to port 8080 while still allowing incoming from the localhost to access 3128. More specific detail is currently beyond the scope of these instructions.

ipchains method 2 - sneaky method

A really sneaky method would be to configure squid to work as a transparent proxy and redirect all port 80 traffic to port 8080. You would want to include method 1 as well. More specific detail is currently beyond the scope of these instructions. There is a HOWTO by Michael C. Jett that I believe covers this.



Client Configuration

Simple config

Lets assume you have a lovely Linux server at ip 192.168.0.1 which is a proxy to the Internet and intranet web server. On this server you have DansGuardian installed listening on port 8080.

You need to configure the client browser for http proxy 192.168.0.1 with port 8080. You can configure ftp the same as http - it is reported to work. That's it. But for efficiency you might want to set the 'no proxy on' to your local Apache server address - 192.168.0.1 in this case. If you've got DNS working, you can use the DNS address of your local server. I tend not to.

Sneaky Config

If you've used the sneaky method to configure squid then there should be no configuration required. Configure your browser for no proxy and maybe set the 'no proxy on' to your local Apache server address - 192.168.0.1 in this case.

Beebug(Daniel's) Config

This could be known as super sneaky I suppose. The problem with the simple config method is that you have to configure by hand every browser. This is a pain and is why the sneaky method is really quite good.
The way Beebug solve this is by using a custom in-house vb app that loads upon login and modifies the needed windows registry and various files so that IE and Netscape (including email) are totally configured automatically. It's so good, you can just stick a copy of netscape on a server in a share and run this program at login and it automatically just works on all the PCs. No installation and a central copy so it's easy to update.
It also has other features such as removing unwanted bits such as web folders, gmt/bst auto switching (already done by login script), app data, and other fixes.
Unless I persuade the directors to release it open source you can't use this method without paying or writing your own. And guess who wrote this - yes - yours truly!

Support

For all support issues, join the mailing list and post your question or comment there.

If you feel your message is not suitable for public viewing and is private (for example asking for pricing or other commercial issues) then email me direct. My address is daniel at jadeb dot com.

You can also get further help from the DansGuardian web site dansguardian.org.

Any comments about this document, email Daniel.