Skip to main content

HOFFA: httpd, OpenBSD, flat-files, and awk

Upon learning that OpenBSD was discontinuing sqlite in the base system, I joked that the BCHS web stack would need to drop sqlite and investigate new options for a web-stack available purely in the OpenBSD base system. So continuing that joke, I proposed the HOFFA web stack: httpd, OpenBSD, flat-files, and awk.

Server configuration

This walk-through assumes you've managed to follow one of the many fine OpenBSD installation guides and now have a fresh OpenBSD system with no packages installed.

Begin by copying the template httpd.conf into the /etc directory:

$ doas cp /etc/examples/httpd.conf /etc/

Next, edit /etc/httpd.conf and in your server block, add a location directive to point to your cgi-bin/ directory (this is relative to your chroot so the absolute path ends up being /var/www/cgi-bin/ by default)

server "" {
    location "/cgi-bin/*" {
        root "/"

Now with the web server configured, it, and the slowcgi proxy need to be enabled.

$ doas rcctl enable slowcgi
$ doas rcctl enable httpd
$ doas rcctl start slowcgi
$ doas rcctl check slowcgi
$ doas rcctl start httpd
(the rcctl check slowcgi may be optional but it doesn't hurt to confirm that it's running)

Populating binaries & libraries in the $CHROOT

With the server and CGI proxy running, binaries need to be put where they'll be found. As this is HOFFA this uses awk

$ doas cp `which awk` /var/www/bin/
then create the library directories and copy in the needed libraries. First, find out which libraries awk needs:
$ ldd `which awk`
 Start    End      Type  Open Ref GrpRef Name
 17b0e000 37b20000 exe   1    0   0      /usr/bin/awk
 05321000 2532c000 rlib  0    1   0      /usr/lib/
 07f46000 27f76000 rlib  0    1   0      /usr/lib/
 02875000 02875000 0    1   0      /usr/libexec/
so we need to create those library directories in the $CHROOT
$ doas mkdir -p /var/www/usr/lib /var/www/usr/libexec
and copy the libraries in
$ doas cp /usr/lib/lib[mc].so* /var/www/usr/lib/
$ doas cp /usr/libexec/ /var/www/usr/libexec/
$CHROOT/bin and its required libraries in their respective places.