SETTING UP 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 – no vhosts

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

#user=thttpd

with vhosts and CGI

dir=/data/www
cgipat=**.cgi|/cgi-bin/*
logfile=/var/log/thttpd.log
pidfile=/var/run/thttpd.pid
port=80
user=thttpd
chroot
vhost

no need to specify charset, UTF-8 is (now?) the default

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

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

stop

pkill thttpd

ACCEPTANCE

curl -s localhost/

OPERATIONS

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

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 

REDIRECT CUSTOM

unhappy with thttpd’s redirect? not flexible enough? try mine – sorry it is an HTML redirect, not a server-side HTTP

#!/bin/sh

cat <<EOF
Content-type: text/html

<!DOCTYPE html>
<html>
<head>
   <meta http-equiv="refresh" content="0; url=http://pub.nethence.com$SCRIPT_NAME">
</head>
</html>
EOF

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