LinuxCommandLibrary

darkhttpd

simple, fast, and secure static web server

TLDR

Serve the current directory on the default port

$ darkhttpd .
copy
Serve a specific directory on a custom port
$ darkhttpd [/path/to/webroot] --port [8080]
copy
Bind to a specific address
$ darkhttpd . --addr [127.0.0.1]
copy
Enable directory listing
$ darkhttpd . --index
copy
Set a custom index file
$ darkhttpd . --index [home.html]
copy
Serve with logging to stdout
$ darkhttpd . --log -
copy
Serve with virtual hosting
$ darkhttpd . --forward [example.com] [http://backend:8000]
copy
Run as a daemon (background)
$ darkhttpd . --daemon --pidfile [/var/run/darkhttpd.pid]
copy

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 can be enabled with the --index flag (without a filename argument). Custom index files can be specified 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: 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 (or flag alone enables directory listing).
--no-listing
Disable directory listing.
--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.
--forward host url
Forward requests for host to URL.
--forward-https host url
Forward HTTPS-originated requests.
--no-keepalive
Disable HTTP keep-alive.
--mimetypes file
Load MIME types from file.

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.

SEE ALSO

nginx(8), python3(1), caddy(1), lighttpd(8), busybox(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community