A web server for 2.11 BSD running on the PiDP-11/70
The original thread discussing the server can be found at https://groups.google.com/g/pidp-11/c/nE5W6wAEIxA/m/7mGpfjAYAwAJ
The current version:
- Supports static file retrieval (HTML and images)
- Supports CGI GET and POST requests
- Assumes web root is /home/www
- Assumes CGI root is /home/www/cgi-bin
- Places HTTP headers in the environment for CGI programs
- Passes QUERY_STRING and CONTENT_LENGTH enviroment variables, aligning with Apache HTTPD CGI
- Only supports HTTP (insecure)
- Welcomes further contributions
I’ve added passing of request header data to the CGI program’s environment. Constraints on the amount of data that will be passed are set conservatively. The stdin channel has been set to unbuffered so that CGI applications called with POST will be able to read the content.
Also, I’ve created a version of Dr. Nim (ESR 1960’s mechanical computer game) as a proof-of-concept for accessing the request parameters and content. That code is available in my https://github.com/DaveRead/2.11BSD-Dr.Nim repository.
I’ve recently made these changes to httpd.c, which I’m running on my PiDP-11 at http://chasecovello.ddns.net/:
- Logging with source IP, date, HTTP request, response code, and file size or error message. Make sure /usr/adm/httpd.log exists and has correct permissions or all requests will return an HTTP 500.
- Rudimentary CGI support. It will execute non-setuid/setuid binaries only if they are in a path that includes cgi-bin somewhere. It doesn’t pass an environment because I didn’t need it.
- More robust error checking and some buffer overrun fixes.
- Use of a buffer and fread/fwrite to serve the file instead of fgetc/fputc. It’s noticeably faster now.
I’ve made a few more changes since the last version; I will be including this one in the new 2.11BSD disk image for testing. I think it’s time I set up a github repo, but for now the new httpd.c is attached, along with a Makefile to make rebuilding and installing easier.
The big changes are:
Added a 60 second timeout to kill the httpd process if the client fails to complete the HTTP request. I noticed after a few days I have several httpd processes sitting there and I got tired of manually killing them. Changed document dir to /home/www because /home has much more free space than / on the PiDP-11 2.11BSD disk image. Tuned the buffer size to save memory; testing shows little to no performance improvement beyond 64 bytes when serving big files. I went with 256 for no real reason other than it’s not too big and not too small. Below are the test results for a 30MB file from my system:
BUF_SIZE SPEED (kB/s) 1 20 2 36 4 44 8 90 16 120 32 120 64 125 128 125 256 125
This web server rapidly grew into something very different and reasonably powerful. Strongly recommended that you use the later versions, which can be found on the PiDP-11 google groups. At the time of writing, the latest version is https://groups.google.com/forum/#!msg/pidp-11/nE5W6wAEIxA/7mGpfjAYAwAJ
A small, and fairly bad, web server which runs under 2.11BSD.
- Only supports GET.
- Will send images, add your own MIME types if you like.
- Assumes web root is
/var/www - Probably insecure.
- Contributions very welcome.
If my PDP-11 is running, you can see the page it hosts at http://catbert.rhwyd.co.uk or alternative http://emubert.rhwyd.co.uk
Copy httpd.c to your PDP-11, compile it and move the binary to the proper place:
cc httpd.c -o httpd mv httpd /usr/libexec/httpd
Append the following line to /etc/inetd.conf
http stream tcp nowait nobody /usr/libexec/tcpd httpd
or
http stream tcp nowait nobody /usr/libexec/httpd httpd
using tcpd instead of directly calling httpd (you can if you
like), will allow you to user your hosts.allow file to limit
access. If inetd was compiled with -DPARANOID (it probably was),
it will also block hosts which have wrong reverse DNS records, which
may not be desirable.
Append the following line to /etc/services
http 80/tcp
Find the process ID of inetd and send it a HUP:
ps aux | grep inetd kill -HUP <PID>
Finally, create /var/www/index.html, along with your other files,
and ensure they are readable by nobody, or world readable.
