---
name: "bozohttpd"
section: "8"
platform: "linux"
package: "bozohttpd"
version: "20111118-1"
release: "Debian 7 (Wheezy)"
platforms: ["linux"]
url: "https://new.carta.tech/bozohttpd"
---

# bozohttpd(8)

hyper text transfer protocol version 1.1 daemon

## NAME

**bozohttpd** – hyper text transfer protocol version 1.1 daemon

## SYNOPSIS

**bozohttpd** \[**-HVXbefnrus**\] \[**-C** *suffix* *cgihandler*\] \[**-I** *port*\] \[**-M** *suffix* *type* *encoding* *encoding11*\] \[**-P** *pidfile*\] \[**-S** *server\_software*\] \[**-c** *cgibin*\] \[**-i** *address*\] \[**-p** *pubdir*\] \[**-t** *chrootdir*\] \[**-v** *virtualroot*\] \[**-x** *index*\] \[**-Z** *cert* *privkey*\] *slashdir* \[*myname*\]

## DESCRIPTION

The **bozohttpd** program reads a *HTTP* request from the standard input, and sends a reply to the standard output. Besides ~user translation and virtual hosting support (see below), all file requests are from *slashdir* directory. The server uses *myname* as its name, which defaults to the local hostname, obtained from [gethostname(3)](/gethostname/3.md) (but see the **-v** option for virtual hosting.) **bozohttpd** writes logs to [syslog(3)](/syslog/3.md) using the ftp facaility (but see the **-s** option for testing.) **bozohttpd** is designed to be small, simple and relatively featureless, hopefully increasing its security.

### OPTIONS

The following options are available:

- **-b**

  Enables daemon mode, where **bozohttpd** detaches from the current terminal, running in the background and servicing HTTP requests.

- **-C** *suffix* *cgihandler*

  Adds a new CGI handler program for a particular file type. The *suffix* should be any normal file suffix, and the *cgihandler* should be a full path to an interpreter. This option is the only way to enable CGI programs that exist outside of the cgibin directory to be executed. Multiple **-C** options may be passed.

- **-c** *cgibin*

  Enables the CGI/1.1 interface. The *cgibin* directory is expected to contain the CGI programs to be used. **bozohttpd** looks for URL's in the form of */cgi-bin/scriptname* where ⟨scriptname⟩ is a valid CGI program in the *cgibin* directory. In other words, all CGI URL's must begin with */cgi-bin/*. Note that the CGI/1.1 interface is not available with *~user* translation.

- **-e**

  Causes **bozohttpd** to not clear the environment when used with either the **-t** or **-U** options.

- **-f**

  Stops the **-b** flag from **bozohttpd** detaching from the tty and going into the background.

- **-H**

  Causes directory index mode to hide files and directories that start with a period, except for *..*. Also see **-X**.

- **-I** *port*

  Causes *port* to use used as the port to bind daemon mode. The default is the “http” port. This option is only valid with the **-b** option.

- **-i** *address*

  Causes *address* to use used as the address to bind daemon mode. If otherwise unspecified, the address used to bind is derived from the *myname*, which defaults to the name returned by [gethostname(3)](/gethostname/3.md). Only the last **-i** option is used. This option is only valid with the **-b** option.

- **-M** *suffix* *type* *encoding* *encoding11*

  Adds a new entry to the table that converts file suffixes to content type and encoding. This option takes four additional arguments containing the file prefix, its “Content-Type”, “Content-Encoding”, and “Content-Encoding” for HTTP/1.1 connections, respectively. If any of these are a single dash (“-”), the empty string is used instead. Multiple **-M** options may be passed.

- **-n**

  Stops **bozohttpd** from doing IP address to name resolution of hosts for setting the REMOTE\_HOST variable before running a CGI program. This option has no effect without the **-c** option.

- **-P** *pidfile*

  Causes **bozohttpd** to create a pid file in *pidfile* when run in daemon mode with the **-b** option.

- **-p** *pubdir*

  Changes the default user directory for */~user/* translations from “public\_html” to *pubdir*.

- **-r**

  Forces pages besides the “index.html” (see the **-X** option) page to require that the Referrer: header be present and refer to this web server, otherwise a redirect to the “index.html” page will be returned instead.

- **-S** *server\_software*

  Sets the internal server version to *server\_software*.

- **-s**

  Forces logging to be set to stderr always.

- **-t** *chrootdir*

  Makes **bozohttpd** chroot to the specified directory before answering requests. Every other path should be specified relative to the new root, if this option is used. Note that the current environment is normally replaced with an empty environment with this option, unless the **-e** option is also used.

- **-U** *username*

  Causes **bozohttpd** to switch to the user and the groups of *username* after initialization. This option, like **-t** above, causes **bozohttpd** to clear the environment unless the **-e** option is given.

- **-u**

  Enables the transformation of Uniform Resource Locators of the form */~user/* into the the directory *~user/public\_html* (but see the **-p** option above).

- **-V**

  Sets the default virtual host directory to *slashdir*. If no directory exists in *virtualroot* for the request, then *slashdir* will be used. The default behaviour is to return 404 (Not Found.)

- **-v** *virtualroot*

  Enables virtual hosting support. Directories in *virtualroot* will be searched for a matching virtual host name, when parsing the HTML request. If a matching name is found, it will be used as both the server's real name, \[*myname*\], and as the *slashdir*. See the EXAMPLES section for an example of using this option.

- **-X**

  Enables directory indexing. A directory index will be generated only when the default file (i.e. *index.html* normally) is not present.

- **-x** *index*

  Changes the default file read for directories from “index.html” to *index*.

- **-Z** *certificate\_path* *privatekey\_path*

  Sets the path to the server certificate file and the private key file in pem format. It also causes **bozohttpd** to start SSL mode.

Note that in **bozohttpd** versions 20031005 and prior that supported the **-C** and **-M** options, they took a single space-separated argument that was parsed. since version 20040828, they take multiple options (2 in the case of **-C** and 4 in the case of **-M**.)

### INETD CONFIGURATION

As **bozohttpd** uses [inetd(8)](/inetd/8.md) by default to process incoming TCP connections for HTTP requests (but see the **-b** option), **bozohttpd** has little internal networking knowledge. (Indeed, you can run it on the command line with little change of functionality.) A typical [inetd.conf(5)](/inetd.conf/5.md) entry would be:

```
http stream tcp  nowait:600 httpd /usr/pkg/libexec/bozohttpd bozohttpd /var/www
http stream tcp6 nowait:600 httpd /usr/pkg/libexec/bozohttpd bozohttpd /var/www
```

This would serve web pages from */var/www* on both IPv4 and IPv6 ports. The *:600* changes the requests per minute to 600, up from the [inetd(8)](/inetd/8.md) default of 40.

Using the NetBSD [inetd(8)](/inetd/8.md), you can provide multiple IP-address based HTTP servers by having multiple listening ports with different configurations.

### NOTES

This server supports the *HTTP/0.9*, *HTTP/1.0*, and *HTTP/1.1* standards. Support for these protocols is very minimal and many optional features are not supported.

**bozohttpd** can be compiled without CGI support (NO\_CGIBIN\_SUPPORT), user transformations (NO\_USER\_SUPPORT), directory index support (NO\_DIRINDEX\_SUPPORT), daemon mode support (NO\_DAEMON\_MODE), and dynamic MIME content (NO\_DYNAMIC\_CONTENT), and SSL support (NO\_SSL\_SUPPORT) by defining the listed macros when building **bozohttpd**.

### HTTP BASIC AUTHORISATION

**bozohttpd** has support for HTTP Basic Authorisation. If a file named *.htpasswd* exists in the directory of the current request, **bozohttpd** will restrict access to documents in that directory using the RFC 2617 HTTP “Basic” authentication scheme.

Note: This does not recursively protect any sub-directories.

The *.htpasswd* file contains lines delimited with a colon containing usernames and passwords hashed with [crypt(3)](/crypt/3.md), for example:

```
heather:$1$pZWI4tH/$DzDPl63i6VvVRv2lJNV7k1
jeremy:A.xewbx2DpQ8I
```

On NetBSD, the pwhash(1) utility may be used to generate hashed passwords.

While **bozohttpd** distributed with NetBSD has support for HTTP Basic Authorisation enabled by default, in the portable distribution it is excluded. Compile **bozohttpd** with “-DDO\_HTPASSWD” on the compiler command line to enable this support. It may require linking with the crypt library, using “-lcrypt”.

### SSL SUPPORT

**bozohttpd** has support for SSLv2, SSLv3, and TLSv1 protocols that is included by default. It requires linking with the crypto and ssl library, using “-lcrypto -lssl”. To disable SSL SUPPORT compile **bozohttpd** with “-DNO\_SSL\_SUPPORT” on the compiler command line.

## FILES

**bozohttpd** looks for a couple of special files in directories that allow certain features to be provided on a per-directory basis. In addition to the *.htpasswd* used by HTTP basic authorisation, if a *.bzdirect* file is found (contents are irrelevant) **bozohttpd** will allow direct access even with the **-r** option. If a *.bzredirect* symbolic link is found, **bozohttpd** will perform a smart redirect to the target of this symlink. The target is assumed to live on the same server. If a *.bzabsredirect* symbolic link is found, **bozohttpd** will redirect to the absolute url pointed to by this symlink. This is useful to redirect to different servers.

## EXAMPLES

To configure set of virtual hosts, one would use an [inetd.conf(5)](/inetd.conf/5.md) entry like:

```
http stream tcp  nowait:600 httpd /usr/pkg/libexec/bozohttpd bozohttpd -v /var/vroot /var/www
```

and inside */var/vroot* create a directory (or a symlink to a directory) with the same name as the virtual host, for each virtual host. Lookups for these names are done in a case-insensitive manner.

To use **bozohttpd** with PHP, one must use the **-C** option to specify a CGI handler for a particular file type. Typically this will be like:

```
bozohttpd -C .php /usr/pkg/bin/php /var/www
```

## SEE ALSO

[inetd.conf(5)](/inetd.conf/5.md), [inetd(8)](/inetd/8.md)

## HISTORY

The **bozohttpd** program was first written in perl, based on another perl http server called “tinyhttpd”. It was then rewritten from scratch in perl, and then once again in C. The focus has always been simplicity and security, with minimal features and regular code audits. This manual documents **bozohttpd** version 20100920.

## AUTHORS

**bozohttpd** was written by Matthew R. Green ⟨mrg@eterna.com.au⟩.

The large list of contributors includes:

- Arnaud Lacombe ⟨alc@netbsd.org⟩ provided some clean up for memory leaks

- Christoph Badura ⟨bad@bsd.de⟩ provided Range: header support

- Sean Boudreau ⟨seanb@NetBSD.org⟩ provided a security fix for virtual hosting

- Julian Coleman ⟨jdc@coris.org.uk⟩ provided an IPv6 bugfix

- Chuck Cranor ⟨chuck@research.att.com⟩ provided cgi-bin support fixes, and more

- DEGROOTE Arnaud ⟨degroote@netbsd.org⟩ provided a fix for daemon mode

- Andrew Doran ⟨ad@netbsd.org⟩ provided directory indexing support

- Per Ekman ⟨pek@pdc.kth.se⟩ provided a fix for a minor (non-security) buffer overflow condition

- Alistair G. Crooks ⟨agc@netbsd.org⟩ cleaned up many internal interfaces, made bozohttpd linkable as a library and provided the lua binding.

- Jun-ichiro itojun Hagino, KAME ⟨itojun@iijlab.net⟩ provided initial IPv6 support

- Martin Husemann ⟨martin@netbsd.org⟩ provided .bzabsredirect support

- Arto Huusko ⟨arto.huusko@pp2.inet.fi⟩ provided fixes cgi-bin

- Roland Illig ⟨roland.illig@gmx.de⟩ provided some off-by-one fixes

- Zak Johnson ⟨zakj@nox.cx⟩ provided cgi-bin enhancements

- Nicolas Jombart ⟨ecu@ipv42.net⟩ provided fixes for HTTP basic authorisation support

- Thomas Klausner ⟨wiz@danbala.ifoer.tuwien.ac.at⟩ provided many fixes and enhancements for the man page

- Johnny Lam ⟨jlam@netbsd.org⟩ provided man page fixes

- Luke Mewburn ⟨lukem@netbsd.org⟩ provided many various fixes, including cgi-bin fixes and enhancements, HTTP basic authorisation support and much code clean up

- Jeremy C. Reed ⟨reed@netbsd.org⟩ provided several clean up fixes, and man page updates

- Scott Reynolds ⟨scottr@netbsd.org⟩ provided various fixes

- Tyler Retzlaff ⟨rtr@eterna.com.au⟩ provided SSL support, cgi-bin fixes and much other random other stuff

- rudolf ⟨netbsd@eq.cz⟩ provided minor compile fixes and a CGI content map fix

- Steve Rumble ⟨rumble@ephemeral.org⟩ provided the **-V** option.

- Joerg Sonnenberger ⟨joerg@netbsd.org⟩ implemented If-Modified-Since support

- ISIHARA Takanori ⟨ishit@oak.dti.ne.jp⟩ provided a man page fix

- Holger Weiss ⟨holger@CIS.FU-Berlin.DE⟩ provided http authorisation fixes

- ⟨xs@kittenz.org⟩ provided chroot and change-to-user support, and other various fixes

- Coyote Point provided various CGI fixes

- Julio Merino added pidfile support and provided some man page fixes

There are probably others I have forgotten (let me know if you care)

Please send all updates to **bozohttpd** to ⟨mrg@eterna.com.au⟩ for inclusion in future releaases.

## BUGS

**bozohttpd** does not handle HTTP/1.1 chunked input from the client yet.
