[Toybox] httpd: How is this supposed to be _used_?

Oliver Webb aquahobbyist at proton.me
Sat Apr 13 12:09:16 PDT 2024


I've been doing networking stuff (Setting up a website),
and since I don't want to deal with Apache or the systemd stuff
required to do nginx. I decided to give toybox httpd a try.
My use case is as simple as simple can be for this type of work,
providing some statically generated web pages on localhost so I
don't have to deal with "/index.html" linking to my actual root
directory when I try to navigate. This practically seems to be
what httpd was made for and should be easy to do.

The first thing I ran into is that httpd doesn't do that by default,
running "toybox httpd dist/" won't actually host those pages
on localhost. "Why?": Looking at the source code and typing
input into httpd, it wants input from stdin and seemingly outputs to
stdout like a normal unix tool (which httpd is usually not).

So, it's supposed to get http requests from... somewhere, and
in return it outputs the stuff you ask for... somewhere. And
you apparently have to know where and/or how to use it in a
pipeline for it to become useful.

Forgive me, but I'm going to compare this to busybox httpd.
A command that needs root privileges (Which makes sense).
So when I do "sudo busybox httpd -h dist/", it automatically
fires that off in the background and provides my webpages on
localhost.

The first line of httpd.c describes the command as "Web server",
and the command help says "Serve contents of directory as static web pages.",
Neither of which provide much insight, or give clues on how you are supposed to
use the "HTTP Daemon" with this behavior.

I'm assuming there's some file in /proc I need to cat into toybox httpd and
redirect the output to somewhere (also likely in /proc) to actually "Serve"
these webpages. But I've grepped through the list archives and I can't find
discussion on how httpd is actually supposed to be used. Busybox httpd calls:

bind(3, {sa_family=AF_INET6, sin6_port=htons(80), sin6_flowinfo=htonl(0), inet_pton(AF_INET6, "::", &sin6_addr), sin6_scope_id=0}, 28)

Which isn't particularly insightful and makes this seem like a internal thing.

This question probably seems stupid to a networking person, but I've looked far and
wide, the busybox source code for httpd (all 2899 lines of it) isn't that insightful.
And if there is documentation for the /proc/net networking stuff that handles this I
don't know where to find it. How is toybox httpd supposed to be used as to "Serve Web Pages"
on a network?

-   Oliver Webb <aquahobbyist at proton.me>



More information about the Toybox mailing list