Cascade HTTP Configuration File

The configuration file used by Cascade HTTP is specified on the command line when the Java interpreter is run.

    java uk.co.demon.cascade.http.HTTPServer www.conf

The configuration file is a simple text file, which is processed line by line on startup. Lines beginning with a # character are treated as comments.

Directives recognised within the configuration file are described below.

AddType

This directive defines which mime-type should be associated with a given file extension.

    AddType    .html       text/html
    AddType    .htm        text/html
    AddType    .dcr        application/x-director

ClassExec

Specifies that a URL matching the given pattern should cause the specified java classes to be loaded and run. The classes specified must be in the CLASSPATH and implement the interface uk.co.demon.cascade.http.HTTPServerExtension. A single asterisk may be used in the URL as a wildcard.

    # Define a class-bin
    Exec   /class-bin/*     uk.co.demon.cascade.ServerExtensions.*

    # Run all accesses to this subtree through my class
    Exec   /users/davidw/secret/*   com.bar.foo.SecretClass

DefaultDocument

This directive defines what the default document name is. If a request is made to access a directory, then the default document name is loaded.

    DefaultDocument  index.html

DocumentRoot

This directive defines where documents are found on the server. Any URLs requested which do not match an explicit rule (Map, Pass, Exec, ClassExec) will be assumed to reside under DocumentRoot.

    DocumentRoot  /usr/www/docs

Exec

Specifies that a URL matching the given pattern should cause the specified program to be run. A single asterisk may be used in the URL as a wildcard.

    # Location of cgi-bin
    Exec   /cgi-bin/*     /usr/www/cgi-bin/*

    # Run all accesses to this subtree through a script
    Exec   /users/davidw/secret/*   /usr/www/cgi-bin/secretScript

Include

Include a separate configuration file here.

    # Keep mime-types in a separate file
    Include /etc/mime.types

Log

Log accesses to specified URLs using the specified Logging class.

    Log class_name file_name pattern

Two standard logging classes are provided: uk.co.demon.cascade.http.AccessLog and uk.co.demon.cascade.http.RefererLog.

For example

    # Log all accesses
    Log uk.co.demon.cascade.http.AccessLog /var/log/cascade.access /*

    # Log all cgi accesses separately
    Log uk.co.demon.cascade.http.AccessLog /var/log/cgi.access /cgi-bin/*
    Log uk.co.demon.cascade.http.AccessLog /var/log/cgi.access /other-bin/*

    # See who has links to our site
    Log uk.co.demon.cascade.http.RefererLog /var/log/referers /*	

Map

Specifies that a URL matching the given pattern should be rewritten. Matches against later rules will continue to take place, but using the 'rewritten' form of the URL. A single asterisk may be used in the URL as a wildcard.

    # Our imagemap program has changed name
    Map   /cgi-bin/htimage/*   /local-bin/imagemap/*

    # Somebody saved all their .html files as .htm by mistake
    Map   /users/xxx/*.html    /users/xxx/*.htm

Pass

Specifies that a URL matching the given pattern should be mapped onto the specified location in the file system. A single asterisk may be used in the URL as a wildcard.

    # Fun things are kept in David's home directory
    Pass   /fun/*   /home/davidw/web/fun/*

    # Document tree 'old_stuff' has moved, map everything in this tree
    # onto a page giving details of the new location
    Pass  /old_stuff/*  /usr/www/web/new_location.html

Port

The Port directive specifies which port the server should listen for requests on. The default port number is 80.

    Port  8080

ServerRoot

The ServerRoot directive specifies where the server resides.

    ServerRoot  /usr/www