Overview
Add a --profile tls option to docker-compose that enables HTTPS on the Nginx caching proxy with zero manual configuration. Certificates are auto-generated on first run if not present.
🎯 User Experience Goals
| Goal |
Solution |
| One command |
make docker-tls or docker compose --profile tls up -d |
| Auto-generates certs |
Init container creates self-signed certs if missing |
| Custom certs supported |
Drop CA-signed certs in ./certs/ before starting |
| No config editing |
Profile-based activation, no manual uncommenting |
| Composable |
Works with --profile monitoring, --profile benchmark |
📋 Tasks
Phase 1: Create TLS-enabled nginx config
Phase 2: Add cert_init service
Phase 3: Add nginx TLS profile override
Phase 4: Makefile integration
Phase 5: Documentation
🔧 Implementation Details
cert_init service:
cert_init:
image: alpine/openssl:latest
volumes:
- ./certs:/certs
entrypoint: ["/bin/sh", "-c"]
command:
- |
if [ -f /certs/cert.pem ] && [ -f /certs/key.pem ]; then
echo "✅ Certificates found in ./certs - using existing"
exit 0
fi
echo "🔏 Generating self-signed TLS certificate..."
mkdir -p /certs
openssl req -x509 -newkey rsa:4096 -sha256 -days 365 -nodes \
-keyout /certs/key.pem -out /certs/cert.pem \
-subj "/CN=localhost" \
-addext "subjectAltName=DNS:localhost,DNS:gateway,DNS:nginx,IP:127.0.0.1"
chmod 644 /certs/cert.pem
chmod 640 /certs/key.pem
echo "✅ TLS certificate generated in ./certs"
profiles: ["tls"]
Makefile targets:
docker-tls: ## Start with TLS enabled (auto-generates certs)
docker compose --profile tls up -d
docker-tls-down: ## Stop TLS-enabled stack
docker compose --profile tls down
✅ Acceptance Criteria
🧠 Environment Info
| Key |
Value |
| Component |
infra/nginx/, docker-compose.yml, Makefile |
| New files |
infra/nginx/nginx-tls.conf |
| Modified files |
docker-compose.yml, Makefile |
📎 Related
- Existing targets:
make certs, make serve-ssl
- Existing profiles:
monitoring, testing, benchmark
- nginx config:
infra/nginx/nginx.conf
Overview
Add a
--profile tlsoption to docker-compose that enables HTTPS on the Nginx caching proxy with zero manual configuration. Certificates are auto-generated on first run if not present.🎯 User Experience Goals
make docker-tlsordocker compose --profile tls up -d./certs/before starting--profile monitoring,--profile benchmark📋 Tasks
Phase 1: Create TLS-enabled nginx config
infra/nginx/nginx-tls.confwith SSL enabled (copy of nginx.conf with SSL blocks uncommented)Phase 2: Add cert_init service
cert_initservice to docker-compose.yml (profile: tls)alpine/opensslimage (small, has openssl)./certs/cert.pemdoesn't existmake certsPhase 3: Add nginx TLS profile override
profiles: ["tls"]./certs:/app/certs:ronginx-tls.confinstead ofnginx.conf8443:443depends_on: cert_initwithservice_completed_successfullyPhase 4: Makefile integration
make docker-tlstargetmake docker-tls-downtargetPhase 5: Documentation
🔧 Implementation Details
cert_init service:
Makefile targets:
✅ Acceptance Criteria
make docker-tlsstarts stack with HTTPS on port 8443./certs/./certs/are used instead of generating new ones/servers/*/sse)/servers/*/ws)https://localhost:8443/admindocker compose --profile tls --profile monitoring up -d🧠 Environment Info
infra/nginx/,docker-compose.yml,Makefileinfra/nginx/nginx-tls.confdocker-compose.yml,Makefile📎 Related
make certs,make serve-sslmonitoring,testing,benchmarkinfra/nginx/nginx.conf