Darkhttpd-Ultra-small Static Http Server
Darkhttpd server is a very small static http server, only 36KB after compilation, but it can complete the functions of ftp and http.
- Simple to set up:
- Single binary, no other files, no installation needed.
- Standalone, doesn't need
- No messing around with config files - all you have to specify is the
- 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.
sendfile()on FreeBSD, Solaris and Linux.
- Can use acceptfilter on FreeBSD.
- At some point worked on FreeBSD, Linux, OpenBSD, Solaris.
- ISC license.
- suckless.org says darkhttpd sucks less.
- Can log accesses, including Referer and User-Agent.
- Can chroot.
- Can drop privileges.
- Impervious to
- 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:
apt-get install git -y #debian use
The following is the universal installation code:
cd darkhttpd #Enter the directory
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:
I explain this sentence.
/ 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
Serve / var / www / htdocs on the default port (80 runs as root, otherwise 8080):
Serve on port 8081 ~ / public_html:
Only bind to one IP address (useful on multi-homed systems):
Up to 4 connections can be connected at the same time:
Log access file:
Chroot For additional security (you need root permission chroot):
Use default.htm instead of index.html:
Add mimetypes-in this case, provide the .dat file as text / plain:
text / plain dat
$ ./darkhttpd / var / www / htdocs --mimetypes extramime
Use acceptfilter (FreeBSD only):
$ ./darkhttpd / var / www / htdocs --accf
Run in the background and create a pidfile:
Web forwarding (301) requests some hosts:
Web forwarding (301) requests all hosts:
Command line options can be combined:
To view the complete list of command line options, run darkhttpd without any parameters:
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.