Simple NetBSD webserver
In a world filled with complex and overwhelming online resources, there may be a need for a simple, reliable server to meet basic web requirements. Among the few trustworthy operating systems available, NetBSD 11 stands out as a viable choice for hosting a web server. This article will outline the straightforward process of setting up a web server using NetBSD 11 and bozohttpd, a minimalistic web server that requires just one additional package for HTTPS support.
Prior to diving into the installation process, one must have access to a VPS, local machine, or virtual machine, alongside a terminal emulator and a web browser (although curl can suffice for basic checks). The author recommends netcup as a hosting service, appreciating its affordability and the availability of a preloaded NetBSD 11 AMD64 ISO.
NetBSD includes a basic web server, bozohttpd(8), which, while somewhat limited, offers flexibility through marker files and command line options. A popular alternative to bozohttpd is inetd(8), but the author found the latter to be less desirable due to its resource-intensive nature. Instead, bozohttpd can function as a standalone daemon. Configuration is achieved through command line options, which can be conveniently stored in /etc/rc.conf with self-explanatory keys.
To serve files from a specific directory, ensure their existence in /var/www/my_magical_domain/index.html. After starting bozohttpd with /etc/rc.d/httpd, your webpage will be accessible via plain HTTP. For added security, obtain an SSL certificate from Let's Encrypt using the acme-client package (installed via pkgin). This involves creating the necessary directories for challenge files and certificate storage, and configuring acme-client.conf to obtain the required certificates.
Once the certificate is in place and the domain's A record is updated, restart bozohttpd to enable HTTPS support on port 443. To maintain certificate validity, set up a cron job that periodically renews the SSL certificate and restarts bozohttpd using acme-client(1).
While bozohttpd is a straightforward web server, it does offer additional features such as virtual hosts, CGI support, and http basic authorization. More advanced functionalities like Lua scripting and URL rewrites may also be explored for enhanced functionality. For those seeking further alternatives to NetBSD, 9front and TempleOS are other options, though the latter lacks network support.
Written by urgent.news from Lobsters's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.