Title HTTP Server Daemon
Status Completed
Start Date 7-2003
Start Date 1-2004
Version 1.7

HTTP Server Usage

The goal of this project was to create a straight-forward web server that would be useful for the modern internet. This program is for those who want a small web server, not for those who want to comply with all standards. Some features that were specified in the HTTP RFCs were left out because they would make the code too large. However, this program should work well for many people, and is mostly indistinguishable from any other server.

Invocation: The server makes its root as the value of the PWD environment variable. So to start it, cd to the directory you want as your web root and execute it. It is probably easiest to put the executable in one of the directories that is in your PATH such as /usr/bin so that it can be executed from any directory. The server does not do a chroot, it just adds the web root string to the beginning of every request. By default, the server will bind to port 80. To change the port, simply put the port number as a parameter on the command line when executing. Linux only lets root bind to ports less than 1000, so changing the port is useful for allowing non-root users to start the server. Upon starting, the SIGHUP signal is set to be ignored, so you may close your terminal safely without closing the server.

Configuration: The runtime configuration options were minimized to make the execution environment more stable. All options that are allowed are set in a directory called admin in the web root. This directory does not have to be present for the server to function. There are two things that may be looked at in this directory. One is a subdirectory called list that contains gif images for directory listings. You can easily configure your directory listings by copying gif images to this directory and naming them so that they are of the form extension.gif (ex: a jpeg image icon would be jpg.gif). Two special cases are directory.gif and default.gif, which are for directories and any extension that is not in the list directory, respectively. If the admin and/or list directories are not present, the server has compiled-in images for directory.gif and default.gif. The other item in the admin directory is a file called 'realms.txt'. This contains the passwords and realms for HTTP authentication. Each line in this file is of the form: 'username:password realm'. The last field, realm, is the file or directory that you want password protected. When parsing this file, the server checks if the request starts with the second field of any line in the file. You can have multiple users per realm by listing them on separate lines. Be sure to have the colon between the username and password and if the realm is a directory, be sure to have a '/' at the end. If you make an admin directory with a realms.txt file, be sure to add an entry to the realms.txt file to restrict access to itself or else anyone can read the password file and that defeats the purpose. (ex: admin:mypass /admin/ ). You don't have to worry about access to the list directory, that can't be password protected. Note: this server uses the basic authentication scheme, which just encodes the password in base64, so if someone is sniffing your connection, they can trivially obtain your password.

Logging: All log messages are sent to stdout. If you want a log file, then use the output redirection ">> ./admin/serverlog" on the command line.