Press "Enter" to skip to content


Clear all

Darkhttpd-Ultra-small Static Http Server  

Posts: 34
Eminent Member
Joined: 1 month ago

Darkhttpd server is a very small static http server, only 36KB after compilation, but it can complete the functions of ftp and http.

darkhttpd-1.12.tar.bz2 (20,184 bytes)
or: darkhttpd.c
or: git clone  (http works too)
or: browse the darkhttpd gitweb.


  • Simple to set up:
    • Single binary, no other files, no installation needed.
    • Standalone, doesn't need inetd or ucspi-tcp.
    • No messing around with config files - all you have to specify is the www root.
  • 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.
  • ISC license.
  • says darkhttpd sucks less.


  • Can log accesses, including Referer and User-Agent.
  • Can chroot.
  • Can drop privileges.
  • Impervious to /../ sniffing.
  • Times out idle connections.
  • Drops overly long requests.


  • Only serves static content - no CGI.


How to compile darkhttpd?
Install git on the server first, then get all the files:

yum install git -y #centos use
apt-get install git -y #debian use

The following is the universal installation code:

git clone # Then get all files
cd darkhttpd #Enter the directory
make #Compile

This completes the installation. Is not it simple?.

It will be easier to use in the future, because you have already compiled it, save a copy of the darkhttpd file in the / darkhttpd / directory, and use it directly next time (don't forget the permissions.)

The easiest way to use:

./darkhttpd / root --port 8081 --daemon

I explain this sentence.

./darkhttpd #Run darkhttpd service
/ root #darkhttpd server's main directory location
--port 8081 #access port, generally use 80, but as you wish , other ports need ip + port access
--daemon # background

Other functions:


Serve / var / www / htdocs on the default port (80 runs as root, otherwise 8080):

$ ./darkhttpd / var / www / htdocs

Serve on port 8081 ~ / public_html:

$ ./darkhttpd ~ / public_html --port 8081

Only bind to one IP address (useful on multi-homed systems):

$ ./darkhttpd ~ / public_html --addr

Up to 4 connections can be connected at the same time:

$ ./darkhttpd ~ / public_html --maxconn 4

Log access file:

$ ./darkhttpd ~ / public_html --log access.log

Chroot For additional security (you need root permission chroot):

$ ./darkhttpd / var / www / htdocs --chroot

Use default.htm instead of index.html:

$ ./darkhttpd / var / www / htdocs --index default.htm

Add mimetypes-in this case, provide the .dat file as text / plain:

$ cat extramime
text / plain dat
$ ./darkhttpd / var / www / htdocs --mimetypes extramime

Remove permissions:

$ ./darkhttpd / var / www / htdocs --uid www --gid www

Use acceptfilter (FreeBSD only):

$ kldload accf_http
$ ./darkhttpd / var / www / htdocs --accf

Run in the background and create a pidfile:

$ ./darkhttpd / var / www / htdocs --pidfile /var/run/ --daemon

Web forwarding (301) requests some hosts:

$ ./darkhttpd / var / www / htdocs --forward \

Web forwarding (301) requests all hosts:

$ ./darkhttpd / var / www / htdocs --forward \

Command line options can be combined:

$ ./darkhttpd ~ / public_html --port 8080 --addr

To view the complete list of command line options, run darkhttpd without any parameters:

$ ./darkhttpd


This server can be integrated with the webui of aria2, so that the download pressure of aria2 can be dispersed. Aria2 uses port 6800, and darkhttpd uses port 6801, and can build online webui. Of course, specific interests can be studied on their own. This darkhttpd function is far more powerful than imagined.

Topic Tags