Der vorliegende Artikel habe ich ursprünglich irgendwann einmal ab 2002 auf meinem damaligen Linux-Entwicklungsserver im Web publiziert. Da ich das bloggen erst 2005 entdeckt habe, waren die Tipps in einer grossen HTML-Seite untergebracht. Anlässlich einer Aufräumaktion auf dem Server habe ich mich entschieden, die „Perlen“ über meine heutige Kommunikationsplattform ins Web zu posaunen. Seitdem ich die Artikel verfasst habe, sind viele Tage ins Land gegangen — ob der Artikel noch Gültigkeit hat, entscheidet der geneigte Leser selber.
Recently, I noticed msnbot was spamming my whole upload bandwidth because it seemed to create a complete dump of my photo gallery – several image requests within a minute! After some googling I discovered several Apache modules which promise to get rid of such bots running amok (although there are some concerns about artificially prolonging download times for leechers – beware!). I finally decided to go on with mod_bwshare. In a temporary „dust of war“, I got the wrong impression that I needed to upgrade to Apache 2.0.x to be able to get a precompiled .deb. Well, haha! There isn’t a debian package available right now. Well, okey, at least I’m running the newest Apache now, although I had to
apt-get remove apache dpkg-reconfigure php4 dpkg-reconfigure php4-mysql dpkg-reconfigure php4-curl dpkg-reconfigure php4-imap dpkg-reconfigure php4-gd
to get back to my „touched working system“ and make PHP aware of Apache 2. Be aware: Everything starts with untouched config files, so make sure you enable error logging in PHP again. Especially if you’re a web-dev like I am, you know about usefulness of
error_reporting = E_ALL
Okey, now straight back to the task. Since all this stuff is open source, we could at least give it a try with compiling and stuff (honestly, I just now enough about compiling to completly havoc a system, but I was a lucky guy in this case). So download the source files:
cd /tmp wget http://www.topology.org/src/bwshare/bwshare-0.1.3.zip unzip bwshare-0.1.3.zip
So, there we had’em now, hundreds of lines of codes. As stated on the developers homepage itself, running
cd src/modules/bwshare apxs2 -c mod_bwshare.c apxs2 -i mod_bwshare.la
Should do the trick. Nada, first we needed the developer package:
apt-get install apache2-dev
Once again:
apxs2 -c mod_bwshare.c apxs2 -i mod_bwshare.la
A lot of warnings were displayed, but finally, I read
... chmod 644 /usr/lib/apache2/modules/mod_bwshare.so
After having succesfully compiled mod_bwshare, I had to create two text-files in /etc/apache2/mods-available/
bwshare.load bwshare.conf
and pasted the following contents:
LoadModule bwshare_module /usr/lib/apache2/modules/mod_bwshare.so
# Some bandwidth control parameters. BW_tx1cred_rate 2 BW_tx1debt_max 10 BW_tx2cred_rate 1000 BW_tx2debt_max 1000000 <Location /bwshare-info> SetHandler bwshare-info </Location> <Location /bwshare-trace> SetHandler bwshare-trace </Location> </IfModule>
That was it (if you got that far, you surely know now what comes next – putting symlinks in mods-enabled/ and doing a
apache2ctl graceful
(Thanks to our solaris master Aeschlimann at the University for the graceful hint some time ago – greetz).