Apache 2 bandwidth limiting

From Nocrashwiki

Limiting bandwidth in Apache 2

Get the latest source from http://bwmod.sourceforge.net/ or a possibly older version from here.

Can configure different settings for each virtual host!

<VirtualHost *:80>
        ServerAdmin 
        [email protected] 
        ServerName www.nocrash.net
        DocumentRoot /var/www/html/nocrash
        BandWidthModule On
        ForceBandWidthModule On
        BandWidth 10.0.0.0/24 0
        #Bandwidth all 22000
        #MinBandwidth all 5000
        #This limits files over (or equal to) 300kb to 10kbytes/s
        #LargeFileLimit .jpg 300 10000
        <Directory /var/www/perl/www>
            AddOutputFilterByType MOD_BW image/jpeg image/jpg
            LargeFileLimit * 300 15000
        </Directory>
        RewriteEngine on
        RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
</VirtualHost>


Fix for mod_bw when getting an error "undefined symbol: apr_atomic_cas" I downloaded the Apache module mod_bw to see if I could simulate some "slow" connections. To compile the package you need to run the following command as root:

# apxs -i -a -c mod_bw.c


That will install the module correctly, but when you add the configuration option to your vhost configs you might get an error "undefined symbol: apr_atomic_cas". When that happens, open the file mod_bw.c and change the following:

Before:

/* Compatibility for ARP < 1 */
#if (APR_MAJOR_VERSION < 1)
   #define apr_atomic_inc32 apr_atomic_inc
   #define apr_atomic_dec32 apr_atomic_dec
   #define apr_atomic_add32 apr_atomic_add
   #define apr_atomic_cas32 apr_atomic_cas
   #define apr_atomic_set32 apr_atomic_set
#endif


AFTER


/* Compatibility for ARP < 1 */
/*
#if (APR_MAJOR_VERSION < 1)
  #define apr_atomic_inc32 apr_atomic_inc
  #define apr_atomic_dec32 apr_atomic_dec
  #define apr_atomic_add32 apr_atomic_add
  #define apr_atomic_cas32 apr_atomic_cas
  #define apr_atomic_set32 apr_atomic_set
#endif
*/

Now, recompile:

# apxs -i -a -c mod_bw.c

Main Page