… running in a QEMU virtual machine using Windows httpd (based on NCSA HTTPd), the first web server for Microsoft Windows—created in the early 90s./cgi-win/scrgrab.exe. The computer’s time zone is set to Europe/Berlin.
I learned that someone is running Windows 95 and the included Personal Web Server on Uberspace—which made me think, “hold my beer,” and this is the result. Also, this was a fun ride through the history of the Internet—reminding me that most of the basics are still the same.
Windows for Workgroups 3.11 runs in QEMU on a small Linux server, which emulates a Pentium with 16 MB of RAM. Inside the VM, there’s Windows httpd running, along with a self-written utility to capture a screen shot via CGI.
You may call it cheating, but to prevent people from exploiting or overloading this tiny server, I’ve put an NGINX reverse proxy in front of it that does some filtering and caching: it only forwards GET requests for this page, the favicon, and the screenshot, strips all request headers and query strings, and lets only a few requests through at a time. The expiry times are just 10 seconds though, as you may have noticed by looking at the clock in the screen shot above. So there is a high probabilty that this server response was generated just for you.
The VM’s hard disk isn’t an image file that I keep tinkering with. Instead, every file of drive C: lives in a Git repository—CONFIG.SYS, AUTOEXEC.BAT, and all the INI files included—and a build script turns them into a bootable FAT16 disk image using mtools. This page is part of the same repository and gets copied straight into the web server’s document root. Every change is a commit, and the same commit always produces the exact same disk image. The VM runs in snapshot mode, so whatever happens inside it is gone with the next restart.
There were a few challenges that I had to overcome.
By default, an emulated Windows 3.11 causes a CPU utilization of 100% on the host (limited to one core, of course)—even when it has nothing to do. That’s because Windows 3.11 never tells the CPU to take a break, so QEMU keeps emulating an endless idle loop at full speed. Not nice. Luckily, there is a utility called DOSidle which I found in a thread at VOGONS. This reduces the CPU usage to an acceptable amount.
With a recent QEMU version, Windows would sometimes hang on a black screen right after the startup logo—and on the next attempt, it would boot just fine. The culprit is Microsoft’s network driver, NDIS.386. At startup, it measures how fast the CPU runs an empty loop by timing it against a millisecond clock, and then divides by the result. On today’s hardware, the loop finishes in less than a millisecond, the measured time is zero, and the division by zero takes down Windows without any message.
Starting Windows with win /n (no network) avoids the problem, but a web server without a network isn’t much use. Luckily, patcher9x knows how to fix the driver: it makes the loop run long enough to be measured and adds a check that prevents the division by zero.
I noticed that the machine’s clock (shown on the screenshot above) loses sync over time. After the server had been running for a few days, the clock was lagging behind by a some seconds. Setting driftfix=slew option on the QEMU command-line didn’t fix this issue. Also, at the time of writing, Europe still observes daylight savings time which Windows 3.11 doesn’t respect.
Side note: Later Windows versions (such as Windows 95) added support for daylight saving time changes, but were cautious: they asked the user during system start-up to confirm whether automatic change had been performed correctly.
So what do you do to keep our computer clock in sync? You use NTP! Oh, wait—even though RFC 958 was written in 1985, NTP wasn’t a thing in Windows 3.11. But, luckily, third-party tools would fill this gap. One of them is Tardis.
To my surprise, it almost worked out of the box. I just had to replace the pre-defined server and set the protocol to “SNTP”. I’ve also ticked “Start minimized” and added it to the Startup folder. No more clock sync issues! And even daylight saving changes are supported. 🥳
There’s a catch, though: this machine isn’t supposed to talk to the Internet. Its network is a private link to the host, and the firewall lets exactly two things through: HTTP requests from the reverse proxy, and NTP requests to the host, which runs its own time server. So instead of a public NTP pool, Tardis asks 10.0.2.2—the host’s side of that link—for the time. Should anyone ever break into this 30-year-old TCP/IP stack, there’s not much they could reach from here.
There were more challenges, some of which I coudn’t solve yet. I’m going to amend this section over time.