Skip to content

Latest commit

 

History

History
146 lines (105 loc) · 3.34 KB

File metadata and controls

146 lines (105 loc) · 3.34 KB

simple-httpd Docker Deployment

Example compose file. The daemon still needs a document root and a config that matches the container paths — see docs/operations.md and docs/configuration.md.

Environment names use underscores (SIMPLE_HTTPD_*). Hyphenated names are ignored.

Quick Start

  1. Build the Docker image from the repository root (wherever your Dockerfile lives):

    docker build -t simple-httpd:latest .
  2. Run with Docker Compose:

    docker-compose up -d
  3. Check status:

    docker-compose ps
    docker-compose logs simple-httpd
    curl -sS http://127.0.0.1/healthz

Configuration

Environment Variables

These are the variables the binary actually reads:

Variable Sets
SIMPLE_HTTPD_CONFIG Config path if --config is omitted
SIMPLE_HTTPD_LOG_LEVEL debug, info, warn, error
SIMPLE_HTTPD_ADDRESS listen_address
SIMPLE_HTTPD_PORT listen_port
SIMPLE_HTTPD_ROOT document_root
SIMPLE_HTTPD_TLS_CERT / SIMPLE_HTTPD_TLS_KEY PEM paths

A config file is the better place for TLS, vhosts, and rate limits.

Volumes

Volume Description
./config:/etc/simple-httpd:ro Configuration and htpasswd (read-only)
./www:/var/www/html:ro Document root (adjust to match document_root)
./logs:/var/log/simple-httpd Access and error logs

Docker Compose Commands

# Start services
docker-compose up -d

# Stop services
docker-compose down

# View logs
docker-compose logs -f simple-httpd

# Restart service
docker-compose restart simple-httpd

# Update and restart
docker-compose pull
docker-compose up -d

# Remove everything
docker-compose down -v

Health Checks

Prefer HTTP:

curl -fsS http://127.0.0.1:80/healthz

nc -z only proves the port is open. /healthz proves the accept loop is serving.

Networking

The service uses a custom bridge network (simple-httpd-network) with subnet 172.22.0.0/16.

Security Considerations

  1. Run as non-root user (configured in Dockerfile)
  2. Read-only configuration volume
  3. Network isolation with custom bridge
  4. Resource limits (configure as needed)

Troubleshooting

Container won't start

# Check logs
docker-compose logs simple-httpd

# Check configuration
docker-compose exec simple-httpd cat /etc/simple-httpd/simple-httpd.conf

Port conflicts

# Check what's using the port
netstat -tlnp | grep 80

# Change port in docker-compose.yml
ports:
  - "8080:80/tcp"

Permission issues

# Fix volume permissions
sudo chown -R 1000:1000 ./logs

Production Deployment

For production deployments, consider:

  1. Use specific image tags instead of latest
  2. Set resource limits in docker-compose.yml
  3. Configure log rotation for log volumes
  4. Use secrets management for sensitive configuration
  5. Set up monitoring and alerting
  6. Configure backup for data volumes

Examples

Development

# Override configuration for development
docker-compose -f docker-compose.yml -f docker-compose.dev.yml up -d

Production

# Use production configuration
docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d