Lighttpd Web Server
Lightweight, high-performance web server for static content.
Overview
Lighttpd (pronounced 'lighty') is an open-source web server designed specifically for high-performance environments where memory usage and CPU efficiency are critical. Originally developed by Jan Kneschke in 2003, lighttpd was created to address the C10k problem—serving thousands of concurrent connections on a single server with minimal resource consumption. Unlike heavyweight servers like Apache, lighttpd uses an event-driven architecture with a single-threaded design that excels at serving static content while consuming significantly less memory, typically using only 1-2MB of RAM for basic operations.
This Docker stack leverages the sebp/lighttpd image to provide an instantly deployable web server that mounts your local htdocs directory directly into the container's document root at /var/www/localhost/htdocs. The configuration automatically exposes port 80 and creates an isolated bridge network, making it perfect for serving static websites, documentation sites, or acting as a frontend for single-page applications. The container's restart policy ensures continuous availability while maintaining lighttpd's signature low resource footprint.
This setup is ideal for developers building static sites, system administrators managing resource-constrained environments, or anyone running web services on Raspberry Pi devices, VPS instances with limited RAM, or edge computing scenarios. The combination of lighttpd's minimal overhead and Docker's portability makes it particularly valuable for IoT projects, development environments, and production deployments where every megabyte of memory matters.
Key Features
- Event-driven architecture handling thousands of concurrent connections with minimal memory usage
- Native FastCGI support enabling PHP integration through external spawn-fcgi containers
- Built-in URL rewriting and redirection capabilities for modern web application routing
- Automatic MIME type detection and customizable content-type headers for static assets
- Conditional configuration system allowing environment-specific server behavior
- HTTP/1.1 keep-alive connections reducing connection overhead for multiple requests
- Built-in access logging and error reporting with customizable log formats
- SSL/TLS termination support with configurable cipher suites and certificate management
Common Use Cases
- 1Serving static documentation sites generated by Jekyll, Hugo, or Gatsby with minimal server resources
- 2Hosting single-page applications built with React, Vue, or Angular that only need static file delivery
- 3Running lightweight web services on Raspberry Pi clusters or IoT edge devices with memory constraints
- 4Providing high-performance static asset delivery for microservice architectures requiring fast content serving
- 5Creating development environments for frontend projects that need realistic HTTP serving behavior
- 6Deploying landing pages or marketing sites on budget VPS instances with limited RAM allocations
- 7Setting up reverse proxy frontends that serve static content while forwarding dynamic requests to backend services
Prerequisites
- Docker Engine 20.10+ and Docker Compose V2 for container orchestration support
- Minimum 512MB available RAM (lighttpd uses 1-2MB but container overhead requires additional memory)
- Port 80 available on host system or modify port mapping to use alternative ports like 8080
- Local htdocs directory with appropriate file permissions for volume mounting
- Basic understanding of HTTP server concepts and static file serving principles
- Familiarity with lighttpd configuration syntax if planning to customize /etc/lighttpd/lighttpd.conf
For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms
docker-compose.yml
docker-compose.yml
1services: 2 lighttpd: 3 image: sebp/lighttpd4 container_name: lighttpd5 restart: unless-stopped6 volumes: 7 - ./htdocs:/var/www/localhost/htdocs8 ports: 9 - "80:80"10 networks: 11 - lighttpd-network1213networks: 14 lighttpd-network: 15 driver: bridge.env Template
.env
1# No environment variables requiredUsage Notes
- 1Docs: https://redmine.lighttpd.net/projects/lighttpd/wiki
- 2Place static files in ./htdocs - served at http://localhost:80
- 3Very low memory footprint - ideal for Raspberry Pi/embedded
- 4Config in /etc/lighttpd/lighttpd.conf (mount for customization)
- 5FastCGI support for PHP - add spawn-fcgi container
- 6Perfect for serving static sites with minimal resources
Quick Start
terminal
1# 1. Create the compose file2cat > docker-compose.yml << 'EOF'3services:4 lighttpd:5 image: sebp/lighttpd6 container_name: lighttpd7 restart: unless-stopped8 volumes:9 - ./htdocs:/var/www/localhost/htdocs10 ports:11 - "80:80"12 networks:13 - lighttpd-network1415networks:16 lighttpd-network:17 driver: bridge18EOF1920# 2. Create the .env file21cat > .env << 'EOF'22# No environment variables required23EOF2425# 3. Start the services26docker compose up -d2728# 4. View logs29docker compose logs -fOne-Liner
Run this command to download and set up the recipe in one step:
terminal
1curl -fsSL https://docker.recipes/api/recipes/lighttpd/run | bashTroubleshooting
- 403 Forbidden errors when accessing files: Check file permissions in htdocs directory and ensure files are readable by container user (UID 1000)
- Container fails to start with 'bind: address already in use': Another service is using port 80, either stop the conflicting service or change port mapping to '8080:80'
- Static files not updating after changes: Browser caching issue, force refresh with Ctrl+F5 or disable cache in browser developer tools
- Connection refused when accessing localhost:80: Verify container is running with 'docker ps' and check Docker daemon is started
- Empty or missing htdocs directory causing 404 errors: Create ./htdocs directory in same location as docker-compose.yml and add index.html file
- High CPU usage with many concurrent connections: Lighttpd's single-threaded design may bottleneck under extreme load, consider adding multiple lighttpd instances behind a load balancer
Community Notes
Loading...
Loading notes...
Download Recipe Kit
Get all files in a ready-to-deploy package
Includes docker-compose.yml, .env template, README, and license
Ad Space
Shortcuts: C CopyF FavoriteD Download