Home | Published: Feb 17, 2025

Building a website

This guide is unfinished. Right now the instruction are heavily favored toward OpenBSD. It will be made more general in the future.

Prerequisites

You are expected to have the following set up already

The sparknotes

Using OpenBSD, you can use httpd, cron, pf, and acme-client to begin hosting static websites. If your website becomes more complex in the future, OpenBSD provides upgrade paths through relayd. OpenBSD provides example configuration files in /etc/examples.

  1. Allow incoming http(s) connections in your firewall
  2. Allow outgoing connections to letsencrypt in your firewall. This will be used to get HTTPS certificates.
  3. Modify the example acme-client config file to match your domain name
  4. Modify the example httpd config file to match your domain[1].
  5. Enable httpd
  6. Run acme-client in the console (to test if it works)
  7. If it works, create a daily cronjob to renew the certificate. Despite us running this daily, acme-client is smart enough to only reach out to letsencrypt if the certificate is almost out of date.
  8. Put at least an index.html file on your server so that you may test that it works.

Bonus

I like my unprivelaged user to be the owner of the server directory. It allows me to have a git repo sitting directly on the server, and makes editing easier. The directory still has global read/execute permissions, so httpd is able to serve it just fine. And it means once I'm satisfied with my changed, I login to my server, cd to the directory, and type git merge dev, and everything is great.

What's missing from this guide?

While this does get you a site, you're still stuck writing it in raw HTML, which isn't very fun. On top of that, the experience of modifying this site locally is pretty annoying without the right tools. This should be added in the future.