Hacker News
4 years ago by mkovach

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.

4 years ago by torstenvl

I like obhttpd and would like to migrate to it eventually. Cool project!

4 years ago by Voline

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.

4 years ago by torstenvl

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?

4 years ago by hibbelig

Using awk to run CGI scripts is a cool idea. Awk is underrated :-)

4 years ago by pantulis

I did that 20 years ago with Solaris. Was contrived and not the easiest thing, but work it did.

4 years ago by cyberpunk

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 ;)

4 years ago by pantulis

There has been a lot of advances all these years, thank $DEITY.

4 years ago by nwmcsween

Maybe use with https://github.com/nwmcsween/tawk

sample index.html.tawk which can generate index.html

```` <p> {{! cat /proc/cpuinfo }} </p>

````

4 years ago by throwawayboise

Except in this specific example, OpenBSD doesn't have /proc

4 years ago by mrweasel

And it wouldn’t work in a chroot.

4 years ago by nwmcsween

This was an example... Do any command you feel like with that awk script

4 years ago by tyingq

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().

https://news.ycombinator.com/item?id=22085459

4 years ago by mro_name

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

4 years ago by gbrown_

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.

4 years ago by the_trapper

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

4 years ago by LeoPanthera

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.

4 years ago by gbrown_

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.

4 years ago by sigzero

Yeah, I don't see how to contact the actual author.

4 years ago by bifrost

I used to do this with csh to annoy a certain friend, awk would've been pretty good too TBH.

Daily Digest

Get a daily email with the the top stories from Hacker News. No spam, unsubscribe at any time.