When you need a web server in a hurry.
darkhttpd-1.12.tar.bz2 (20,184 bytes)
or: darkhttpd.c
or: git clone https://unix4lyfe.org/git/darkhttpd (http works too)
or: browse the darkhttpd gitweb.
Features:
- Simple to set up:
- Single binary, no other files, no installation needed.
- Standalone, doesn't need
inetdorucspi-tcp. - No messing around with config files - all you have to specify is the
wwwroot.
- Written in C - efficient and portable.
- Small memory footprint.
- Event loop, single threaded - no fork() or pthreads.
- Generates directory listings.
- Supports HTTP GET and HEAD requests.
- Supports Range / partial content. (try streaming music files or resuming a download)
- Supports If-Modified-Since.
- Supports Keep-Alive connections.
- Supports IPv6.
- Can serve 301 redirects based on Host header.
- Uses
sendfile()on FreeBSD, Solaris and Linux. - Can use acceptfilter on FreeBSD.
- At some point worked on FreeBSD, Linux, OpenBSD, Solaris.
- BSD license.
- suckless.org says darkhttpd sucks less.
Security:
- Can log accesses, including Referer and User-Agent.
- Can chroot.
- Can drop privileges.
- Impervious to
/../sniffing. - Times out idle connections.
- Drops overly long requests.
Limitations:
- Only serves static content - no CGI.
History:
- 1.0 - First release.
- 1.1 - Optimized directory listing generation, report CPU usage on exit, Makefile for the terminally lazy.
- 1.2 - Code cleanup, report traffic stats on exit.
- 1.3 - Added
--pidfileand--daemon, a number of portability fixes, usesendfile()on Solaris. - 1.4 - Fixed a segfault in log_connection().
- 1.5 - Minor performance enhancements.
- 1.6 - Fixed use-after-free bug.
- 1.7 - In autogenerated directory listings, URL encode links that need it.
- 1.8 - Fixed large file support on 32-bit Linux, plus minor bug fixes.
- 1.9 - Added
--no-keepalive,--forward,--no-server-id. - 1.10 - Added
--forward-all, strip query parameters from URL. - 1.11 - Security: call setgroups() before setgid().
- 1.12 - Added
--no-listing,--default-mimetype, improve URL escaping, set listing charset to UTF-8, added support for IPv6.
Screenshot:
$ make cc -O2 -fno-strict-aliasing -pipe `[ \`uname\` = "SunOS" ] && echo -lsocket -lnsl` darkhttpd.c -o darkhttpd $ ./darkhttpd ~/public_html darkhttpd/1.7, copyright (c) 2003-2008 Emil Mikulic. listening on 0.0.0.0:80 ^C caught Interrupt: 2, stopping $ _