Files
TimeTracker/docker/generate-mkcert-certs.sh
Dries Peeters 94e8e49439 feat: Add HTTPS support with mkcert and automatic SSL configuration
Add comprehensive HTTPS support with two deployment options:
- mkcert for local development with trusted certificates
- Automatic SSL with Let's Encrypt for production

HTTPS Implementation:
- Add docker-compose.https-mkcert.yml for local HTTPS development
- Add docker-compose.https-auto.yml for automatic SSL certificates
- Create Dockerfile.mkcert for certificate generation
- Add setup scripts (setup-https-mkcert.sh/bat)
- Add startup scripts (start-https.sh/bat)
- Add certificate generation script (generate-mkcert-certs.sh)

CSRF and IP Access Fixes:
- Fix CSRF token validation for IP-based access
- Add CSRF troubleshooting documentation
- Update configuration to handle various access patterns

Documentation:
- Add HTTPS_MKCERT_GUIDE.md with setup instructions
- Add README_HTTPS.md with general HTTPS documentation
- Add README_HTTPS_AUTO.md for automatic SSL setup
- Add AUTOMATIC_HTTPS_SUMMARY.md
- Add CSRF_IP_ACCESS_FIX.md and CSRF_IP_FIX_SUMMARY.md
- Add docs/CSRF_IP_ACCESS_GUIDE.md
- Update main README.md with HTTPS information

Configuration:
- Update .gitignore for SSL certificates and nginx configs
- Update env.example with new HTTPS-related variables
- Update docker-compose.yml with SSL configuration options

This enables secure HTTPS access in both development and production
environments while maintaining compatibility with existing deployments.
2025-10-13 18:32:45 +02:00

69 lines
1.8 KiB
Bash

#!/bin/sh
# Auto-generate mkcert certificates in container
set -e
CERT_DIR="/certs"
CERT_FILE="$CERT_DIR/cert.pem"
KEY_FILE="$CERT_DIR/key.pem"
CA_FILE="$CERT_DIR/rootCA.pem"
echo "=========================================="
echo "mkcert Certificate Generator"
echo "=========================================="
echo ""
# Create cert directory
mkdir -p "$CERT_DIR"
# Check if certificates exist
if [ -f "$CERT_FILE" ] && [ -f "$KEY_FILE" ]; then
echo "✅ Certificates already exist"
exit 0
fi
echo "🔧 Generating mkcert certificates..."
echo ""
# Install local CA (for container use)
mkcert -install
# Get domains/IPs to include
DOMAINS=${CERT_DOMAINS:-"localhost 127.0.0.1 ::1"}
echo "Generating certificate for: $DOMAINS"
echo ""
# Generate certificates
mkcert -key-file "$KEY_FILE" -cert-file "$CERT_FILE" $DOMAINS
# Copy CA certificate for user to install on host
cp "$(mkcert -CAROOT)/rootCA.pem" "$CA_FILE" 2>/dev/null || true
chmod 644 "$CERT_FILE" "$CA_FILE" 2>/dev/null || true
chmod 600 "$KEY_FILE"
echo ""
echo "✅ mkcert certificates generated!"
echo ""
echo "📋 Next steps:"
echo " 1. The certificates are in: nginx/ssl/"
echo " 2. To avoid browser warnings, install rootCA.pem on your host:"
echo ""
echo " Windows:"
echo " - Double-click nginx/ssl/rootCA.pem"
echo " - Install to: Trusted Root Certification Authorities"
echo ""
echo " macOS:"
echo " - Double-click nginx/ssl/rootCA.pem"
echo " - Add to Keychain and mark as trusted"
echo ""
echo " Linux:"
echo " sudo cp nginx/ssl/rootCA.pem /usr/local/share/ca-certificates/mkcert.crt"
echo " sudo update-ca-certificates"
echo ""
echo " 3. Restart your browser"
echo " 4. Access: https://localhost or https://$HOST_IP"
echo ""
echo "=========================================="