When I had a requirement to do this, I used the one true awk and compiled it statically. Didn't require mucking around with all the libraries.
I like obhttpd and would like to migrate to it eventually. Cool project!
I have several servers running it, and Iāve been pretty pleased with it. If you want to try it out you can get an OpenBSD VM at Vultr or OpenBSD.amsterdam for about $6/month.
I also highly recommend Michael W Lucasās book Relayd & Httpd Mastery.
One thing keeping me on Apache I stead of NGINX or obhttpd is how easy it is to do overrides for particular directories. I use this A LOT for generating dynamic content.
Example: Let's say I want to generate an RTF doc for a power of attorney. I'll tell Apache via .htaccess to treat .rtf documents in that directory as CGI scripts. poa.rtf then is a Python script to process the QUERY_STRING or POST parameters into an RTF template and spit it out. End result is that browser requests poa.rtf and gets a file called poa.rtf -- generated on the fly.
Do you have an idea how you'd accomplish the same trickery in obhttpd? I guess you'd have to have the per-directory config in the main config file?
Using awk to run CGI scripts is a cool idea. Awk is underrated :-)
I did that 20 years ago with Solaris. Was contrived and not the easiest thing, but work it did.
I once inherited one such system, it was running on 2.5.1.. My job was to move it to a zone on s10.. It actually pretty much worked, I had to port it forwards to S8, but then word got around that someone had done 'something' to this ancient pile of tech debt and feature requests started coming in so I rewrote it all in perl in an afternoon.. I didn't even try to understand the code, I just used tcpdump to look at the requests/responses and treated it as a black box.
I don't miss this kind of work ;)
There has been a lot of advances all these years, thank $DEITY.
Maybe use with https://github.com/nwmcsween/tawk
sample index.html.tawk which can generate index.html
```` <p> {{! cat /proc/cpuinfo }} </p>
````
Except in this specific example, OpenBSD doesn't have /proc
And it wouldnāt work in a chroot.
This was an example... Do any command you feel like with that awk script
You can also coax gawk into being a web server itself, albeit a bit brain-dead. I wish they would tweak the way it does server sockets so that you could make a decent forking server. As it stands now, you don't get the socket until after the listen() and accept().
I like those tiny bits doing useful things. A lot.
E.g. dump form posts for later (offline) processing: https://codeberg.org/mro/form2xml/src/branch/master/dump.cgi
I replied to someone on Twitter about this as I mistakenly thought they were the author, but the interpreter line in the example script should be #!/usr/bin/awk rather than #!/bin/awk.
The author actually has it right due to OpenBSD's httpd running in a chroot of /var/www.
Edit: nevermind, you're right, just checked it again and the author put the copied awk under /usr/bin inside the chroot
You can use "#!/usr/bin/env awk" to make it universal, this works on all the BSDs and Linux. Works for bash and other interpreters too.
I just wanted to point out typo. I'm aware of the env idiom, though that wouldn't work in the chroot environment described in the article. Short of also copying it to the chroot which would be a bit redundant.
Yeah, I don't see how to contact the actual author.
I used to do this with csh to annoy a certain friend, awk would've been pretty good too TBH.
Get a daily email with the the top stories from Hacker News. No spam, unsubscribe at any time.