Saturday, September 20, 2008

Multiple Instances of DansGuardian on CentOS 4.3

Multiple Instances of DansGuardian on CentOS 4.3
(An adaptation of Ken Samland’s Multiple Instances of DansGuardian on OS X)

PREPARATION

Hopefully you’ve installed CentOS and you have a static IP address. If you didn’t install squid during
the OS setup, don’t worry we get to it. If you did, just skip the squid install section.

BASE SYSTEM

CentOS 4.3

I will assume limited knowledge of Linux. Prompts will be displayed in this document as myproxy>.
Commands to be typed will be in italics.

SOFTWARE

Before you begin, download all the necessary packages and files.

I created a “dg” folder in the /usr/local/src directory. It doesn’t matter. Download the latest stable
release of dansguardian. At the time of this writing 2.8.0.6 was the current stable release.

myproxy>wget http://dansguardian.org/downloads/2/Stable/dansguardian-2.8.0.6.source.tar.gz

INSTALLS

SQUID

1. I used yum to install squid:
myproxy>rpm –import /usr/share/rhn/RPM-GPG-KEY-centos4
myproxy>yum install squid

2. START SQUID
Run the command myproxy>/etc/init.d/squid start
Use chkconfig to enable squid at startup myproxy>chkconfig squid on

DANSGUARDIAN

The first copy takes the longest (about 20 minutes), after that, subsequent copies only take about 5 minutes)

1. Untar/gz dansguardian-2.8.0.6.src.tar.gz
myproxy>tar xvfz dansguardian-2.8.0.6.source.tar.gz

2. Rename dansguardian-2.8.0.6 to dansguardian1
myproxy>mv dansguardian-2.8.0.6 dansguardian1

3. Changed to the dansguardian1 folder, and edit the following files as below…

FILE: configure (2 changes)
LINES:
sysconfdir=’/etc/dansguardian1/’
logdir=’/var/log/dansguardian1/’
SAVE

FILE: autoconfig/linux.in (9 changes)
LINES:
cp -f ./dansguardian $I$(BINARYLOCATION)dansguardian1

cp -f ./dansguardian.bsdv $I$(SYSVLOCATION)dansguardian1.sh
cp -f ./dansguardian.pl $I$(CGIBINLOCATION)dansguardian1.pl
chmod o+x $I$(CGIBINLOCATION)dansguardian1.pl

…$I$(LOGROTATELOCATION)dansguardian1; fi

uninstall:
rm -f $(BINARYLOCATION)dansguardian1
rm -f $(SYSVLOCATION)dansguardian1
rm -f $(CGIBINLOCATION)dansguardian1.pl

…then rm -f $(LOGROTATELOCATION)dansguardian1; fi
SAVE

4. Make a copy of the folder dansguardian1

myproxy>cp -r dansguardian1 dansguardian2

5. Compile dansguardian
myproxy>cd /into/dansguardian1
myproxy>./configure
myproxy>make
myproxy>make install
myproxy>make clean

6. Change directories, go to /etc/dansguardian1 and edit the following file.

FILE: dansguardian.conf
Uncomment and/or change these lines as shown below…

loglocation = ‘/var/log/dansguardian1/access.log’
filterport = 8081 (whatever you choose)
accessdeniedaddress = ‘http://YOURSERVER.YOURDOMAIN/cgi-bin/dansguardian1.pl’
ipcfilename = ‘/tmp/.dguardian1ipc’
urlipcfilename = ‘/tmp/.dguardian1urlipc’
pidfilename = ‘/var/run/dansguardian1.pid’
SAVE

7. Change directories, go to /etc/rc.d/init.d

FILE: dansguardian1

Replace ALL “dansguardian” with “dansguardian1″

YOUR FIRST COPY IS NOW INSTALLED!!! We will start all the copies when we are done.

8. In step 5, you copied the dansguardian1 folder. Now, change directories to the
dansguardian2 directory that we made (/usr/local/src/dansguardian2)

a. Open dansguardian2/configure with VI
b. Replace ALL ‘dansguardian1″ with “dansguardian2″ (2 changes)
c. Open dansguardian2/autoconf/linux.in
d. Replace ALL ‘dansguardian1″ with “dansguardian2″ (9 changes)

9. REPEAT STEPS 3 - 7 with obvious name changes. Do this for as many copies as you need. DON’T FORGET TO CHANGE
THE PORT NUMBER IN STEP 6 FOR EACH INSTANCE OF DANSGUARDIAN! I like to increment the number by 100 each time.
8081, 8181, 8281, etc…

MOMENT OF TRUTH!!!

1. Squid must be running
2. Start both instances of Dansguardian:
myproxy>/etc/rc.d/init.d/dansguardian1 start
myproxy>/etc/rc.d/init.d/dansguardian2 start

Continue this until all your copies are running.

3. Does it work?
a. Go to your favorite Browser, or System Prefs and configure your proxy settings to…

PROXY: Yourserver (or localhost) PORT: your port

b. Try going to a site. You should be able to access it.
c. Try your other Proxy ports
d. If everything looks ok use chkconfig to make it start at boot time.
myproxy>chkconfig dansguardian1 on
myproxy>chkconfig dansguardian2 on

Now you can configure your dansguardian preferences to block/allow content. Remember that you need to edit the
banned sitelists and other files for each instance of dansguardian. However, you can store your blacklists in a central
location that all instances of DansGuardian can access.

No comments: