darkhttpd
simple, fast, and secure static web server
TLDR
SYNOPSIS
darkhttpd docroot [--port port] [--addr address] [--daemon] [--log file] [--index file] [options]
DESCRIPTION
darkhttpd is a simple, fast, and secure static web server. Written in C with no dependencies, it compiles to a single small binary that can serve static files with minimal resource usage.The server is designed for simplicity: it serves files from a document root directory with proper MIME types, handles HTTP/1.1 keep-alive connections, and supports security features like chroot and privilege dropping. There's no configuration file; all options are command-line arguments.Directory listing is enabled by default and can be disabled with --no-listing. Custom index files can be specified with --index to override the default index.html. The server sends proper caching headers and handles range requests for resumable downloads.For production use, darkhttpd supports daemonization, PID file creation, and logging. The chroot and uid/gid options provide security isolation. While not designed for high-traffic sites, it's excellent for local development, embedded systems, or serving static content where simplicity is valued.
PARAMETERS
--port port
Port to listen on (default: 80 when running as root, otherwise 8080).--addr address
Address to bind to (default: all interfaces).--daemon
Fork into background.--pidfile file
Write PID to file when daemonized.--log file
Log requests to file (- for stdout).--index file
Default index file to serve for directory requests (default: index.html).--no-listing
Disable directory listing (directory listing is enabled by default).--timeout seconds
Connection timeout (default: 60).--uid uid
Drop privileges to this user ID.--gid gid
Drop privileges to this group ID.--chroot
Chroot to docroot.--maxconn n
Limit number of simultaneous connections.--forward host url
301 redirect requests with matching Host header to the given URL.--forward-all url
301 redirect all requests to the given URL (catch-all).--forward-https host url
301 redirect HTTP requests for host to HTTPS.--no-keepalive
Disable HTTP keep-alive.--no-server-id
Omit Server identification header from responses.--mimetypes file
Load MIME types from file.--default-mimetype type
Serve files with unknown extensions as this MIME type.--hide-dotfiles
Do not serve files or directories starting with a dot.--single-file file
Serve only the specified file rather than a directory.--auth user:password
Enable HTTP Basic authentication.--syslog
Use syslog for request logging instead of a file.--header header
Add a custom response header (repeatable).
CAVEATS
Static files only; no CGI, PHP, or dynamic content support. No SSL/TLS; use a reverse proxy for HTTPS. No configuration file; all settings via command line. Limited to HTTP/1.1 features. Not suitable for high-concurrency production workloads.
HISTORY
darkhttpd was created by Emil Mikulic in 2003 as a simple, portable HTTP server. The design philosophy emphasizes minimalism and security over features. The single-file C source compiles on virtually any Unix-like system without external dependencies, making it popular for embedded systems and minimal environments.
