Cherokee Web Server: Directory configuration

Directory configuration

The entry Directory encloses a group of directives which will apply only to the named directory and sub-directories of that directory. It allows to define completely diferent behaviors depending on the directories.

The accepted clauses inside a Directory (and Extension) entry are:

A directory entry accepts as many of these configuration entries as you want.


Contents

Paths

Paths of the directory entries are relative to the DocumentRoot of the Virtual Host which contains it. If a new DocumentRoot if defined inside the directory entry, it will become its internal location.


Examples

General DocumentRoot

Lets imagine the virtual server DocumentRoot configuration entry is set to /var/www.

Directory /tarballs {
    Handler file
}

The request /tarballs/cherokee-1.0.0.tar.gz refers to /var/www//tarballs/cherokee-1.0.0.tar.gz


Customized DocumentRoot

As in the previous examples, lets imagine the general DocumentRoot points to /var/www.

Directory /tarballs {
    Handler file
    DocumentRoot /mnt/extra/source_tars/
}

The request /tarballs/cherokee-1.0.0.tar.gz refers to /mnt/extra/source_tars/cherokee-1.0.0.tar.gz


It is very common to use this feature to redefine the path of the /icons and /cgi-bin web directories. A usual configuration is:

Directory /icons {
    Handler file
    DocumentRoot /usr/share/cherokee/icons
}
Directory /cgi-bin {
    Handler cgi
    DocumentRoot /usr/lib/cgi-bin
}

In this way, it is possible to have some paths accessible from the web, outside the main web directory.

Configuration inheritance

Lets imagine the DocumentRoot of the current virtual host is set to /var/www/ directory.

Directory /download {
     Allow From 127.0.0.1, 192.168.0.0/16
}

Directory /download/films {
     DocumentRoot /var/films/
     Handler file
}

The request /download/films/pulpfiction.avi would be processed in this way:


Configuration inheritance (II)

This examples shows that the Directory inheritance mechanism doesn't overwrite settings.

Directory /secrets {
     Allow From 10.0.0.0/8, 127.0.0.1, 192.168.0.0/16
}

Directory /secrets/important {
     Allow From 127.0.0.1
}

The request /secrets/important/file.tar.gz will only success if it is made from localhost. No matters is the connection comes from one of the network ranges described on the /secrets directory.