mod_quotaCodemeridian.net.au

mod_quota

Introduction

mod_quota is an Apache Web Server module which can be used to limit or quota the number of requests on a per directory basis.

The module reads a configuration file which lists the user or directory, the number of requests already made and the number of requests allowed.

The configuration file allows for bytes, but the current implementation does not impose any checks against bytes sent.

Downloads

All files
mod_quota.zip [6,823 bytes]

Individual files
mod_quota.c [19,445 bytes]
Makefile.tmpl [70 bytes]
Makefile [1,888 bytes]
README.txt [2,768 bytes]

The .zip archive contains all the files you need. However, you can also download the files individually if you wish.

Installation

To include this module in your server, follow the steps below:

  1. Install the module in src/modules/mod_quota.
  2. Place the configuration line below into your src/Configuration file. This line should be placed above the userdir_module.

    For Apache 1.2
    Module mod_quota_module modules/ozquota/mod_quota

    For Apache 1.3
    AddModule modules/mod_quota/mod_quota.o

  3. Run the src/Configure script (cd src; ./Configure). This will build the Makefile for the server itself, and update the src/modules/Makefile for any additional modules you have requested from beneath that subdirectory.
  4. Make the server (run make in the src directory).

Configuration

There are five configuration directives available:

Quota On|Off
Enables/disables quota module. Default: Off
QuotaFile file
File that contains quota information.
QuotaCutoff hits
Minimum hits threshold. Only add directory to quota list if hits is greater than cutoff. Useful to trim large quota files.
QuotaNodes nodes
The number of machines (or nodes) in cluster. Essentially, this number is used to divide the quotas in the input file.
QuotaBaseURL URL
Base URL for directory names.

Configuration File Format

An example configuration file is given below.

# This is a comment
# Blank lines are ignored
# User names must start with a ~ character
# Other lines are directories relative to ServerRoot
# Bytes are ignored - no quotas apply

# Directory   Hits   Bytes    QHits  QBytes

/directory1   498    334382   21000  1048576
/directory2   28957  281996   21000  1048576
~user1        8957   3019384  21000  1048576
~user2        56439  2155061  21000  1048576

For the next request

mod_quota Handler

To view information about the mod_quota module, you need to activate the mod_quota handler by including a block similar to the following, in your srm.conf file.

<Location /mod_quota-info>
  SetHandler mod_quota-handler
  order deny,allow
  deny from all
  allow from server.foo.com
</Location>

You can then point your browser to
http://server.foo.com/mod_quota-info

Bugs and Suggestions

Contact me if you have any bugs, problems, or suggestions.