setting up thttpd

requirements

defaults are to use nogroup group and nobody user

    grep ^no /etc/group
    grep ^no /etc/passwd

    grep ^thttpd /etc/group
    grep ^thttpd /etc/passwd
    #groupadd -g 30000 thttpd
    #useradd -r -s /sbin/nologin -M -d /noexist -g thttpd -u 30000 thttpd

install

from source

see thttpd from source

package binaries

slackware

slackpkg install thttpd

netbsd

pkg_add thttpd

/usr/libexec/locate.updatedb
locate thttpd.conf
diff /usr/pkg/etc/thttpd.conf /usr/pkg/share/examples/thttpd.conf
mv /usr/pkg/etc/thttpd.conf /etc/
ln -s /etc/thttpd.conf /usr/pkg/etc/thttpd.conf

cp /usr/pkg/share/examples/rc.d/thttpd /etc/rc.d
echo thttpd=yes >> /etc/rc.conf

setup

cp -pi /etc/thttpd.conf /etc/thttpd.conf.dist
vi /etc/thttpd.conf

quick & dirty for static pages – chroot & no vhosts

dir=/data/www/tmp
logfile=/var/log/thttpd.log
pidfile=/var/run/thttpd.pid
port=8080
chroot

easy CGI pages (w/o chroot) with vhosts

dir=/data/www
logfile=/var/log/thttpd.log
pidfile=/var/run/thttpd.pid
user=thttpd
port=8080
vhost

cgipat=**.cgi|/cgi-bin/*

more options

# nosymlink# default = !chroot
# novhost
# nocgipat
# nothrottles
# host=0.0.0.0
# charset=iso-8859-1

ready to go

start and enable at boot time

vi /etc/rc.local

echo -n thttpd ...
/usr/local/sbin/thttpd -C /etc/thttpd.conf && echo done || echo FAIL

status

netstat --inet --inet6 -lntup | grep 8080
pgrep -a thttpd
ps auxfww | grep httpd | grep -v grep

stop

pkill thttpd

acceptance

curl -s localhost/

ops

tail -F /var/log/thttpd.log                       

vi ~/RESTART-THTTPD 

#!/bin/sh

ps auxww | grep thttpd | grep -v grep
echo -n killing thttpd...
pkill thttpd && echo done

echo -n thttpd...
/usr/local/sbin/thttpd -C /etc/thttpd.conf && echo done
ps auxww | grep thttpd | grep -v grep

chmod +x RESTART-THTTPD 

and something about SIGHUP

additional notes

tls

see stunnel

chroot + cgi

see diy chroot

http redirect

cp thttpd-2.29/cgi-src/redirect /data/www/redirect.cgi
chmod +x /data/www/redirect.cgi

configure the redirect patterns at the root of the data dir w/ or w/o chroot enabled (troubleshoot and find the exact path by test&try, looking at the 404 error message)

vi /data/www/.redirects

/*/*    https://nethence.com/
//.     https://nethence.com/

now choose what domains you need to redirect

ln -s redirect.cgi /data/www/noexist.nethence.com 

basic cgi test

mkdir -p /data/www/localhost/
cd /data/www/localhost/
vi test.cgi

#!/bin/bash

cat <<EOF
Content-type: text/html

<p>thttpd is up and CGI is enabled
EOF

chmod +x test.cgi 
touch favicon.ico
curl -s localhost:8080/test.cgi

resources

Configuration Options http://acme.com/software/thttpd/options.html

thttpd man page http://acme.com/software/thttpd/thttpd_man.html

thttpd notes http://acme.com/software/thttpd/notes.html

redirect man page http://acme.com/software/thttpd/redirect_man.html

thttpd https://en.wikipedia.org/wiki/Thttpd

A fork of Jef Poskanzer’s popular thttpd. https://github.com/blueness/sthttpd

+ssl

tiny / throttling / trivial HTTPd extended with proxy and TLS Pool support https://github.com/arpa2/thttpd-proxy-tlspool

Merecat ∴ Embedded Web Server https://github.com/troglobit/merecat


HOME | GUIDES | LECTURES | LAB | SMTP HEALTH | HTML5 | CONTACT
Copyright © 2024 Pierre-Philipp Braun