obhttpd (OpenBSD HTTPD)

I am trying to get the obhttpd package working, and must be missing a critical step somewhere.

1. Installed the package
pkg install obhttpd

2. Set the service to start on boot (/etc/rc.conf)

Code:
obhttpd_enable="YES"
obhttpd_flags='"

3. Created a basic configuration (/usr/local/etc/obhttpd.conf)

Code:
ext_ip="MY_EXT_IP"

server "default" {
listen on ext_ip port 80
root "/htdocs/default"
}

4. Created the directories and set the permissions

Code:
mkdir -p /var/www/htdocs/default
chown -R www:www /var/www

5. Start the service

service obhttpd start

6. Now I receive an error in /var/log/messages as follows

Code:
lost child: server exited abnormally
lost child: logger exited abnormally

What am I missing?
 
Last edited by a moderator:
Ok, so I have gotten somewhere, if I run obhttpd in the foreground I get some additional logs

Code:
/usr/local/sbin/obhttpd -d -v

startup
fatal: proc_run: chroot: No such file or directory
fatal: proc_run: chroot: No such file or directory
lost child: logger exited abnormally
lost child: server exited abnormally
parent terminating, pid 9058

So what directory is it actually looking for as chroot?

From what I have read the default chroot to /var/www as / which would make make my "htdocs" appear as /var/www/htdocs. Is that right?
 
Last edited by a moderator:
As this appears to be using chroot(8) you'll need to mount some devices on /var/www/dev/ (assuming it chroot(8)s to /var/www/). Aren't there any hints in /usr/local/etc/rc.d/obhttpd?
 
chroot(8) is attempting to change root to a directory that doesn't exist. As the maintainer didn't actually update the obhttpd.conf(8) man page (beyond renaming it), it's not especially clear what the default value of the chroot setting is anymore, but it doesn't appear to be /var/www or /usr/local/var/www.

Try setting the top-level chroot option to a directory of your choosing:

Code:
chroot "/usr/local/var/www"

Provided your chosen root setting is correct relative to your chosen chroot setting, obhttpd should start without complaints.
 
If I interpret the code from http.c below correctly, it defaults to the home directory of 'www', which is /var/www on OpenBSD but /nonexistent on FreeBSD.

Code:
if (env->sc_chroot == NULL)
env->sc_chroot = ps->ps_pw->pw_dir;
for (proc = 0; proc < nitems(procs); proc++)
procs[proc].p_chroot = env->sc_chroot;
 
Ok, so I have gotten somewhere, if I run obhttpd in the foreground I get some additional logs

Code:
/usr/local/sbin/obhttpd -d -v

startup
fatal: proc_run: chroot: No such file or directory
fatal: proc_run: chroot: No such file or directory
lost child: logger exited abnormally
lost child: server exited abnormally
parent terminating, pid 9058

So what directory is it actually looking for as chroot?

From what I have read the default chroot to /var/www as / which would make make my "htdocs" appear as /var/www/htdocs. Is that right?
What was the solution to this?
 
Back
Top