BOZOHTTPD(8)
💅 BOZOHTTPD(8) — hyper text transfer protocol version 1.1 daemon (System Manager's Manual) 🦋
🌸 NAME 🌸
bozohttpd — hyper text transfer protocol version 1.1 daemon. okay bestie, that's the whole name vibe 💖
✨ SYNOPSIS ✨
bozohttpd [-EGHVXdefhnqsu] [-C suffix cgihandler] [-I port]
[-L prefix script] [-M suffix type encoding encoding11]
[-m version] [-P pidfile] [-R readme] [-S version]
[-T type timeout] [-U username] [-Z cert privkey] [-c cgibin]
[-i address] [-p pubdir] [-t chrootdir] [-v virtualroot]
[-x index] [-z ciphers] slashdir [myname]
🫶 DESCRIPTION 🫶
okay so bozohttpd is literally reading a HTTP request from standard input and sending a reply to standard output. besides ~user translation and virtual hosting support (peep below), every file request comes from the slashdir directory. the server uses myname as its name, and that defaults to the local hostname obtained from gethostname(3) — but bestie, check the -v option for virtual hosting 👀
bozohttpd writes logs to syslog(3) using the ftp facility, but see the -s option for testing and the -q option for suppressing that whole situation. bozohttpd is designed to be small, simple and relatively featureless, hopefully increasing its security. it's giving minimalist icon behavior, no cap 💅
✨ OPTIONS ✨
the following options are available, bestie — let's go through the whole menu 🎀
-b— enables daemon mode, wherebozohttpddetaches from the current terminal, runs in the background, and services HTTP requests. main character energy, honestly.-C suffix cgihandler— adds a new CGI handler program for a particular file type. thesuffixshould be any normal file suffix, and thecgihandlershould be a full path to an interpreter. this option is the only way to enable CGI programs that exist outside of thecgibindirectory to be executed. multiple-Coptions may be passed. slay, but carefully 🫶-c cgibin— enables the CGI/1.1 interface. thecgibindirectory is expected to contain the CGI programs to be used.bozohttpdlooks for URL's in the form of/cgi-bin/<scriptname>where⟨scriptname⟩is a valid CGI program in thecgibindirectory. in other words, all CGI URL's must begin with/cgi-bin/. note that the CGI/1.1 interface is available with~usertranslation using the-Eswitch.-d— enables debug support. very useful when the vibe check fails 🔍-E— enables CGI/1.1 interface for~usertranslation. note that enabling this support implies that users can run commands as the web server user. this may have security implications. bestie, that is a real warning, not just drama 💀-e— causesbozohttpdto not clear the environment when used with either the-tor-Uoptions.-f— stops the-bflag from detachingbozohttpdfrom the tty and going into the background. this implies the-bflag.-G— get thebozohttpdversion string, print it on standard output, and exit. short and iconic ✨-H— causes directory index mode to hide files and directories that start with a period, except for.... also see-X.-I port— causesbozohttpdto useportinstead of the default “http” port. when used with the-boption, it changes the bound port. otherwise it forces redirections to use thisportinstead of the value obtained viagetsockname(2).-i address— causesaddressto be used as the address to bind daemon mode. if otherwise unspecified, the address used to bind is derived from themyname, which defaults to the name returned bygethostname(3). only the last-ioption is used. this option is only valid with the-boption.-L prefix script— adds a new Lua script for a particular prefix. theprefixshould be an arbitrary text, and thescriptshould be a full path to a Lua script. multiple-Loptions may be passed. a separate Lua state is created for each prefix. the Lua script can register callbacks using thehttpd.register_handler('<name>', function)Lua function, which will trigger the execution of the Lua functionfunctionwhen a URL in the formhttp://<hostname>/<prefix>/<name>is being accessed. the function is passed three tables as arguments, the server environment, the request headers, and the decoded query string plus any data that was sent asapplication/x-www-form-urlencoded. that's a whole lot of Lua, but it ate 💅-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-Moptions may be passed.-m version— set the minimum supported SSL protocol version. the valid values ofversionare “TLSv1.1”, “TLSv1.2”, and “TLSv1.3”. the default version is “TLSv1.1”.-n— stopsbozohttpdfrom doing IP address to name resolution of remote hosts. this affects theREMOTE_HOSTenvironment variable for CGI programs and Lua scripts.-P pidfile— causesbozohttpdto create a PID file inpidfilewhen run in daemon mode with the-boption.-p pubdir— changes the default user directory for/~user/translations from “public_html” topubdir.-q— quiet mode — no log entries generated. silence is golden, bestie 🤫-R readme— when directory indexing is enabled, include the contents of the filereadmein the footer of the directory index.-S version— sets the internal server version toversion.-s— forces logging to be set tostderralways.-T type timeout— set the timeout fortypetotimeout. the valid values oftypeare “ssl timeout”, “initial timeout”, “header timeout”, and “request timeout”. the default values are 30 seconds, 30 seconds, 10 seconds and 600 seconds, respectively.-t chrootdir— makesbozohttpdchrootto 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-eoption is also used.-U username— causesbozohttpdto switch to the user and the groups ofusernameafter initialization. this option, like-tabove, causesbozohttpdto clear the environment unless the-eoption is given.-u— enables the transformation of Uniform Resource Locators of the form/~user/into the directory~user/public_html(but see the-poption above).-V— sets the backup virtual host directory to theslashdirargument. if no directory exists invirtualrootfor the request, thenslashdirwill be used. the default behavior is to return404(Not Found.)-v virtualroot— enables virtual hosting support. directories invirtualrootwill 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 theslashdir. 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.htmlnormally) is not present.-x index— changes the default file read for directories from “index.html” toindex.-Z certificate_path privatekey_path— sets the path to the server certificate file and the private key file in PEM format. it also causesbozohttpdto start SSL mode. secure vibes activated 🔐-z ciphers— sets the list of SSL ciphers (seeSSL_CTX_set_cipher_list(3)).
okay, tiny time-travel note bestie: inbozohttpdversions20031005and prior that supported the-Cand-Moptions, they took a single space-separated argument that was parsed. since version20040828, they take multiple options (2 in the case of-Cand 4 in the case of-M.)
🌈 INETD CONFIGURATION 🌈
as bozohttpd uses inetd(8) 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) entry would be:
http stream tcp nowait:600 _httpd /usr/libexec/httpd httpd /var/www
http stream tcp6 nowait:600 _httpd /usr/libexec/httpd httpd /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) default of 40.
using the NetBSD inetd(8), you can provide multiple IP-address based HTTP servers by having multiple listening ports with different configurations. iconic little setup, honestly 🎀
🦋 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. lowkey humble of it.
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), dynamic MIME content (NO_DYNAMIC_CONTENT), Lua support (NO_LUA_SUPPORT), and SSL support (NO_SSL_SUPPORT) by defining the listed macros when building bozohttpd. build-time customization, we love to see it ✨
🔐 HTTP BASIC AUTHORIZATION 🔐
bozohttpd has support for HTTP Basic Authorization. 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. bestie, do not assume it protects the whole tree — it literally does not 🫶
the .htpasswd file contains lines delimited with a colon containing user names and passwords hashed with crypt(3), 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 Authorization 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”.
👑 BLOCKLIST SUPPORT 👑
okay so on NetBSD, bozohttpd ships with blocklistd(8) support by default — like it's just there, bestie, doing its thing. you can turn it off with the -DNO_BLOCKLIST_SUPPORT compilation option if that's not your vibe.
when it happens, bozohttpd reports two HTTP status codes to blocklistd(8) as failures:
401(``Unauthorized'')403(``Forbidden'')
of those two, it's 401 that you get when authorization fails through the HTTP Basic Authorization mechanism. and a successful authorization actually decreases the counter blocklistd(8) keeps. slay, forgiveness arc.
⚠️ heads up bestie — the HTTP Basic Authorization mechanism uses a redirection, so a401status code is always initially received. that means a single authorization failure of.htpasswdgets reported as two failures toblocklistd(8), but no failures are recorded on successful authorization, since the failure counter decreases. math is mathing, unfortunately.
🔐 SSL SUPPORT 🔐
bozohttpd has support for the TLSv1.1 and TLSv1.2 protocols, and they're included by default ✨. it does need linking with the crypto and ssl library though, using -lcrypto -lssl. if you want SSL off, compile bozohttpd with -DNO_SSL_SUPPORT on the compiler command line.
want an enforced redirect, like http to https? create a shadow directory root that contains a .bzabsredirect file pointing to the real target. easy, iconic.
🗜️ COMPRESSION 🗜️
bozohttpd supports a very basic form of compression — ngl it's minimal and it knows it. it will serve the requested file postpended with .gz if:
- that file exists
- it is readable
- the client requested gzip compression
- and the client did not make a ranged request
all four, no cap. miss one and the .gz stays on the shelf. 🫶
📁 FILES 📁
bozohttpd looks for a couple of special files in directories, which is how it does per-directory feature stuff. let's go through them:
.htpasswd— this one is used by HTTP basic authorization. gatekeeping, but make it secure 💅.bzredirect— if this symbolic link is found,bozohttpdperforms a smart redirect to the target of said symlink. the target is assumed to live on the same server. if the target starts with a slash, then absolute redirection is performed; otherwise it's handled as relative..bzabsredirect— if this symlink is found,bozohttpdredirects to the absolute URL pointed to by the symlink. super useful for redirecting to different servers 🌈. two forms of redirection are supported:- a symbolic link without schema uses
http://as default — i.e. a link toNetBSD.orgredirects tohttp://NetBSD.org/ - otherwise the provided schema is used — i.e. a symbolic link to
ftp://NetBSD.org/redirects to that provided URL
- a symbolic link without schema uses
.bzremap— if this file is found at the root of a (virtual) server, it's expected to contain rewrite mappings for URLs 🦋.
so about those remappings: they're performed internally in the server before authentication happens, and they can be used to hide implementation details — like the CGI handler specific suffix for non cgi scripts in authorized directories. sneaky but legit.
the map file consists of lines of two paths separated by a colon, where the left side needs to exactly match a (sub) path of the request and will be replaced by the right side. and the first match always wins. periodt.
a .bzremap file could look like this:
/nic/update:/auth-dir/updipv4.pl
⚠️ the remap file should be short — access to it is slow and needs to happen on every single request. if a request path needs to include a colon (:) character, it can be escaped with a backslash (\). and the right hand side of the colon is always used verbatim — no escape sequences are interpreted. none. zero. don't try it.
✨ EXAMPLES ✨
wanna configure a set of virtual hosts? you'd use an inetd.conf(5) entry like this:
http stream tcp nowait:600 _httpd /usr/libexec/httpd httpd -v /var/vroot /var/www
and then inside /var/vroot you 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, and may include the port number part of the request — which lets you have distinct virtual hosts on the same name 😌👑
to use bozohttpd with PHP, you gotta use the -C option to specify a CGI handler for a particular file type. typically it'll be like:
httpd -C .php /usr/pkg/bin/php-cgi /var/www
⚠️ note that a plain script interpreter can not be used directly as acgihandler, because there are no command line options passed frombozohttpd— and that's on purpose, to avoid security issues. safety first, always 💖
if no CGI-aware wrapper exists, a simple shell script like the following might do. it would be invoked like:
httpd -C .pl /www-scripts/bin/run.perl /var/www
and the script could look like:
#! /bin/sh
if [ -r "$SCRIPT_FILENAME" -a -x "$SCRIPT_FILENAME" ]; then
exec /usr/pkg/bin/perl "$SCRIPT_FILENAME"
fi
exit 1
👀 SEE ALSO 👀
go read those if you're nosy, iykyk 🧚
📜 HISTORY 📜
okay so story time bestie 🎀 — bozohttpd was first written in perl, based on another perl http server called "tinyhttpd". then it was rewritten from scratch in perl, and then once again in C. glow-up after glow-up, honestly iconic.
from "bozohttpd" version 20060517, it has been integrated into NetBSD. and the focus has always been simplicity and security, with minimal features and regular code audits. main character energy with a security budget 💅
this manual documents bozohttpd version 20240126.
🫶 AUTHORS 🫶
bozohttpd was written by Matthew R. Green ⟨mrg@eterna23.net⟩.
the large list of contributors includes:
- Christoph Badura ⟨bad@bsd.de⟩ — provided
Range:header support - Marc Balmer ⟨mbalmer@NetBSD.org⟩ — added Lua support for dynamic content creation
- 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
- Alistair G. Crooks ⟨agc@NetBSD.org⟩ — cleaned up many internal interfaces, made
bozohttpdlinkable as a library and provided the Lua binding - DEGROOTE Arnaud ⟨degroote@NetBSD.org⟩ — provided a fix for daemon mode
- Andrew Doran ⟨ad@NetBSD.org⟩ — provided directory indexing support
- Roland Dowdeswell ⟨elric@NetBSD.org⟩ — added support for serving gzipped files and better SSL handling
- Per Ekman ⟨pek@pdc.kth.se⟩ — provided a fix for a minor (non-security) buffer overflow condition
- ⟨emily@ingalls.rocks⟩ — provided fixes for some bad request parsing
- Jun-ichiro itojun Hagino, KAME ⟨itojun@iijlab.net⟩ — provided initial IPv6 support
- Martin Husemann ⟨martin@NetBSD.org⟩ — provided
.bzabsredirectand.bzredirsupport, fixed various redirection issues and more - 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 authorization support
- Antti Kantee ⟨pooka@NetBSD.org⟩ — provided fixes for HTTP basic authorization support
- Thomas Klausner ⟨wiz@NetBSD.org⟩ — provided many fixes and enhancements for the man page
- Mateusz Kocielski ⟨shm@NetBSD.org⟩ — fixed memory leaks, various issues with userdir support, information disclosure issues, added support for using CGI handlers with directory indexing, found several security issues and provided various other fixes
- Arnaud Lacombe ⟨alc@NetBSD.org⟩ — provided some clean up for memory leaks
- Johnny Lam ⟨jlam@NetBSD.org⟩ — provided man page fixes
- Dennis Lindroos ⟨denafcm@gmail.com⟩ — provided a cgi-bin fix
- Jared McNeill ⟨jmcneill@NetBSD.org⟩ — added support for readme in directory indexing
- Julio Merino ⟨jmmv@NetBSD.org⟩ — Added the
-Poption (pidfile support) and provided some man page fixes - Luke Mewburn ⟨lukem@NetBSD.org⟩ — provided many various fixes, including cgi-bin fixes and enhancements, HTTP basic authorization support and much code clean up
- Sunil Nimmagadda ⟨sunil@nimmagadda.net⟩ — provided runtime TLS version control
- Rajeev V. Pillai ⟨rajeev_v_pillai@yahoo.com⟩ — provided several fixes for virtual hosting and directory indexing and fixes for CGI
- 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@eterna23.net⟩ — 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
-Voption - Jukka Ruohonen ⟨jruoho@NetBSD.org⟩ — provided support for
blocklistd(8) - Thor Lancelot Simon ⟨tls@NetBSD.org⟩ — enhanced cgi-bin support
- Joerg Sonnenberger ⟨joerg@NetBSD.org⟩ — implemented
If-Modified-Sincesupport - Kimmo Suominen ⟨kim@NetBSD.org⟩ — removed obsolete
.bzdirecthandling - ISIHARA Takanori ⟨ishit@oak.dti.ne.jp⟩ — provided a man page fix
- Holger Weiss ⟨holger@CIS.FU-Berlin.DE⟩ — provided http authorization fixes
- ⟨xs@kittenz.org⟩ — provided chroot and change-to-user support, and other various fixes
- S.P.Zeidler ⟨spz@NetBSD.org⟩ — fixed several SSL shutdown issues
- Coyote Point — provided various CGI fixes
there are probably others I have forgotten (let me know if you care) 😭
please send all updates to bozohttpd to ⟨mrg@eterna23.net⟩ or ⟨netbsd-bugs@NetBSD.org⟩ for inclusion in future releases. we love a contribution bestie 🫶
💀 BUGS 💀
bozohttpd does not handle HTTP/1.1 chunked input from the client yet. that's it, that's the bug. not me being a hater, just being honest 🫠
✨ and that's the whole page, bestie ✨ this edition came from the fine folks on Debian, dated Jan 26, 2024, and it's the manual for BOZOHTTPD(8) — go forth and serve some files, you've got this 💖🎀🦋
📦 where this page comes from
- nixos 26.05: bozohttpd 20240126
- nixpkgs unstable: bozohttpd 20240126
- Copyright (c) 1997-2024 Matthew R. Green
- 💖 girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms