mod_bwshare is a bandwidth throttling and monitoring per client IP address.

The mod_bwshare module accepts or rejects HTTP requests from each client IP address based on past downloads by that client IP address.

If the HTTP client’s download rate exceeds specified levels, the reponse to the HTTP client is an HTML warning message.

To install bwshare as a DSO module for Apache 2 with all of the paths as in the default source settings, I do the following.

moose /root# /usr/local/apache2/bin/apxs -c mod_bwshare.c
moose /root# /usr/local/apache2/bin/apxs -i
moose /root# /usr/local/apache2/bin/apachectl restart

I had to add the following line to the httpd.conf file first.

LoadModule bwshare_module modules/

I also added this sort of thing in a file bwshare.conf which I included into the httpd.conf file before doing the apachectl restart command:

<IfModule mod_bwshare.c>
    <Location /bwshare-info>
        SetHandler bwshare-info

    <Location /bwshare-trace>
        SetHandler bwshare-trace

    # Some bandwidth control parameters.
    <Directory />
    BW_tx1debt_max          25
    BW_tx1cred_rate         0.095
    BW_tx2debt_max          3000000
    BW_tx2cred_rate         2500

Here’s a typical session:

moose /root# /usr/local/apache2/bin/apxs -c mod_bwshare.c
/usr/local/apache2/build/libtool --silent --mode=compile gcc -prefer-pic
 -I/usr/local/apache2/include  -I/usr/local/apache2/include
 -I/usr/local/apache2/include   -c -o mod_bwshare.lo mod_bwshare.c && touch
/usr/local/apache2/build/libtool --silent --mode=link gcc -o
 -rpath /usr/local/apache2/modules -module -avoid-version    mod_bwshare.lo

moose /root# ls -l mod* .libs
-rw-r--r--  1 root root 152562 Nov 15 22:39 mod_bwshare.c
-rw-r--r--  1 root root    822 Nov 22 19:27
-rw-r--r--  1 root root    324 Nov 22 19:27 mod_bwshare.lo
-rw-r--r--  1 root root 123752 Nov 22 19:27 mod_bwshare.o
-rw-r--r--  1 root root      0 Nov 22 19:27 mod_bwshare.slo

total 337
drwxr-xr-x   2 root root    208 Nov 22 19:27 .
drwx------  20 root root    944 Nov 22 19:27 ..
-rw-r--r--   1 root root 123904 Nov 22 19:27 mod_bwshare.a
lrwxrwxrwx   1 root root     17 Nov 22 19:27 -> ../
-rw-r--r--   1 root root    823 Nov 22 19:27 mod_bwshare.lai
-rw-r--r--   1 root root 123752 Nov 22 19:27 mod_bwshare.o
-rwxr-xr-x   1 root root  85438 Nov 22 19:27

moose /root# /usr/local/apache2/bin/apxs -i
/usr/local/apache2/build/libtool --mode=install cp
cp .libs/ /usr/local/apache2/modules/
cp .libs/mod_bwshare.lai /usr/local/apache2/modules/
cp .libs/mod_bwshare.a /usr/local/apache2/modules/mod_bwshare.a
ranlib /usr/local/apache2/modules/mod_bwshare.a
chmod 644 /usr/local/apache2/modules/mod_bwshare.a
PATH="$PATH:/sbin" ldconfig -n /usr/local/apache2/modules
Libraries have been installed in:

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,--rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and manual pages.
chmod 755 /usr/local/apache2/modules/

moose /root# /usr/local/apache2/bin/apachectl restart


Post By Editor (2,827 Posts)

Website: →