OpenBSD Blog #13: Moving ratfactor.com to OpenBSD.amsterdam
End of an era
Well, it finally happened yesterday. I was unable to SSH into the VM that was hosting this website.
Although the VM was still serving web pages, I couldn’t get ssh to connect on port 22. I rebooted the VM from the management console, but still nothing.
I can say this now that it’s over: That VM was running Slackware 14.2. You read that right, I was serving my website from a distribution of Linux that was released in 2016, TEN YEARS ago. Of course, I had every intention of upgrading the OS, and, later, of moving to OpenBSD. But life kept happening and Slackware kept working.
I don’t think I had a security event. I didn’t see anything concerning in the traffic or logs (monitorable externally). I’m sure I could have salvaged it somehow.
But since I was planning to move anyway, I’ve simply embarked on an emergency crash dive into OpenBSD and a new VM host.
Hello OpenBSD.amsterdam
I’ve actually been with openbsd.amsterdam for two years already, hosting a little private site as a test.
Not only do they run a pure OpenBSD setup (openbsd.amsterdam), they also donate a significant portion of each subscription to the OpenBSD Foundation, which is very cool and feels good.
If you’ve become acclimated to OpenBSD’s man pages, you feel right at home with OpenBSD.amsterdam’s documentation.
Move checklist
The biggest thing I wanted to change was how I was
serving "pretty URLs" (without an .html extension).
My trick was…to simply export pages with no extension and
telling Apache that the default MIME type was HTML! It worked,
but was the source of various hassles, as you might imagine.
I now run OpenBSD’s own native web server, httpd(8). It doesn’t
have as many bells and whistles as Apache, but I fully embrace
OpenBSD’s minimalism. So I’m exporting my pages with .html
extensions like a normal person and figured out the
httpd.conf(5) syntax for internally rewriting the extensionless
URLs.
At the moment this page is a draft, but I’ve got my rewrite
rule updated: OpenBSD httpd Rewrite and Redirects with Examples.
At some point, I will update my
Rat Tools repo. The export
change was made in make.rb.
I deleted all the old extensionless exported pages with another
little script.
(Also, I had been sloppy with my internal URLs, mixing
extensionless page and directory links, often linking to foo
when it should have been foo/. That doesn’t fly with my new URL
rewriting rule, so I need to track down these links. A perfect
task for a Ruby script. I aim to do that soon. In the meantime,
I’m going to have some broken links. At least I got the ones in
the header of each page!)
Lastly, I did the scary part of switching the "ratfactor.com" domain to point to the new server:
-
First, I set up a temporary test domain to make sure the basic site content worked with the aforementioned URL rewriting, etc.
-
To test the httpd setup for the real domain without touching the global DNS system just yet, I edited
/etc/hostson my desktop computer make "ratfactor.com" resolve to the openbsd.amsterdam VM. -
Sadly, without access to the previous machine, I needed to get new certificates from Let’s Encrypt. I had little choice but to switch the real ratfactor.com DNS records to continue. At this point, anyone visiting would get certificate errors, so I wanted to move pretty quickly.
-
I followed my own previous instructions on Dave’s OpenBSD Blog #9: OpenBSD httpd (ACME client for certs) to set up the certificate for TLS.
Conclusion
On one hand, I didn’t enjoy being forced to make the move this weekend. On the other hand, I’ve been wanting to perform this move for several years and now it’s done!
The process of moving the core of my computing from Linux to OpenBSD has been very slow and deliberate. I’ve fit it in as time allowed
This is the third of three articles I hope to be completing soon. This one is being published first because it was the easiest while everything was fresh in my mind today.
I’m looking forward to many happy years of running OpenBSD httpd with the peace of mind that comes from an up-to-date, minimal, and secure OS.