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 mod_bwshare.la
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/mod_bwshare.so

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>

    <Location /bwshare-trace>
        SetHandler bwshare-trace
    </Location>

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

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
 -DAP_HAVE_DESIGNATED_INITIALIZER -DLINUX=2 -D_REENTRANT -D_XOPEN_SOURCE=500
 -D_BSD_SOURCE -D_SVID_SOURCE -D_GNU_SOURCE -g -O2 -pthread
 -I/usr/local/apache2/include  -I/usr/local/apache2/include
 -I/usr/local/apache2/include   -c -o mod_bwshare.lo mod_bwshare.c && touch
 mod_bwshare.slo
/usr/local/apache2/build/libtool --silent --mode=link gcc -o mod_bwshare.la
 -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 mod_bwshare.la
-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

.libs:
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 mod_bwshare.la -> ../mod_bwshare.la
-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 mod_bwshare.so

moose /root# /usr/local/apache2/bin/apxs -i mod_bwshare.la
/usr/local/apache2/build/instdso.sh
 SH_LIBTOOL='/usr/local/apache2/build/libtool' mod_bwshare.la
 /usr/local/apache2/modules
/usr/local/apache2/build/libtool --mode=install cp mod_bwshare.la
 /usr/local/apache2/modules/
cp .libs/mod_bwshare.so /usr/local/apache2/modules/mod_bwshare.so
cp .libs/mod_bwshare.lai /usr/local/apache2/modules/mod_bwshare.la
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:
   /usr/local/apache2/modules

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/ld.so.conf'

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

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

Source: http://www.topology.org

Post By Editor (2,827 Posts)

Website: →

Connect