A web server in dd/sh

Using dd/sh you can write a small but complete web server. Our initial version (written in less than one hour in the train last weekend) supports GET and HEAD methods, HTTP versions 0.9, and 1.0, deals with MIME types the way you'd expect to, and has some form of server script (called "ddsh-bin").

New! Improved! Bugs fixed! New bugs added! The dd/sh web server is now version 0.1. There are two main changes: a security hole plugged, and some syntax which confused the HP=UX shell (and possibly other) has been made more shell friendly. Another minor change now returns redirections when trying to access directories (it adds a slash at the end)

To install it in your system, you need to download the following files:

You might prefer to download the lot in one single click: ddshttpd.tar.gz (2084 bytes).

Decide where your web server documents must go, say /etc/web for example. Obtain and untar the file ddshttpd.tar.gz (2084 bytes) into your chosen location, then edit the file conf/ddshttpd.conf changing the first line to reflect your choice, for example:

    webroot=/etc/web
As you are there, make sure you change the hostname and port variables too, or any redirects will get back to this server!

If you want, you can move things around end edit the rest of the file as appropriate. When you are done, edit /etc/inetd.conf and add the line:

    80 stream tcp nowait nobody /etc/web/bin/ddshttpd ddshttpd /etc/web/conf/ddshttpd.conf
and restart inetd. That's all!

To display static documents, just put them in the docs directory (for example, /etc/web/docs). For server scripts, create a directory ddsh-bin within docs and your scripts will be called with the following four arguments:

The script receives on standard input the header provided by the client. If we get around supporting "POST" the data will follow the header. The script must provide the appropriate header and data on standard output. Standard error is thrown away, but nobody stops you reopening it to a log file.

One day I am going to rewrite this documentation. No, really.