thttpd is a simple, portable, and minimalistic HTTP server. More information from their home page at:

Compiling[edit | edit source]

thttpd can be compiled with plain build utilities. On Alpine Linux, run the following:

# apk add gcc musl-dev make

## Get thttpd and compile
# wget
# tar -xzvf thttpd-2.29.tar.gz
# cd thttpd-2.29

## Compile
# ./configure
# make CCOPT='-O2 -s -static' thttpd
# cd cgi-src
# make STATICFLAG='-O2 -s -static' all

Because the binary is compiled and linked statically, you can run thttpd within an empty container.

Usage[edit | edit source]

Description Command
Start thttpd on port 8080 serving /www thttpd -h -p 8080 -d /www
Allow CGI anywhere thttpd -h -p 8080 -d /www -c **
Log to stdout thttpd -h -p 8080 -d /www -l -
Start thttpd using a configuration file thttpd -C thttpd.conf

Redirection[edit | edit source]

Redirections are handled by a separate CGI program. Included in the source tree is cgi-src/redirect.c which reads a .redirects file for the appropriate destinations.

To get this working:

  1. Compile cgi-src/redirect.c.
  2. Move redirect to your web root. Call it redirect.cgi.
  3. Symlink your source (for example, index.html if you want to redirect the root location) to redirect.cgi
  4. Add / into .redirects.

See also[edit | edit source]