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 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
inetd
orucspi-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.
- 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.
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
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:
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
Other functions:
--------------------
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
Remove permissions:
Use acceptfilter (FreeBSD only):
$ ./darkhttpd / var / www / htdocs --accf
Run in the background and create a pidfile:
Web forwarding (301) requests some hosts:
--forward secure.example.com https://www.example.com/secure
Web forwarding (301) requests all hosts:
--forward-all http://catchall.example.com
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.