A complete n8n automation platform with Caddy reverse proxy, automated refresh capabilities, and cross-platform support for macOS and Ubuntu.
# Generate secure credentials and configure domain
./scripts/generate-secrets.sh
# Start the n8n platform
docker compose up -d# Automatically detects your OS and refreshes services
./scripts/refresh.sh# Set up daily refresh at 2 AM
./scripts/cron/install.sh daily
# Set up weekly refresh on Sunday at 3 AM
./scripts/cron/install.sh weekly
# Set up monthly refresh on 1st at 4 AM
./scripts/cron/install.sh monthly
# Custom schedule (every 6 hours)
./scripts/cron/install.sh custom "0 */6 * * *"
# Remove cron job
./scripts/cron/install.sh remove
# Check status
./scripts/cron/install.sh status# Quick status check
./scripts/cron/check.sh
# Detailed analysis
./scripts/cron/check.sh detailed
# Show help
./scripts/cron/check.sh helphomelab/
βββ docker-compose.yml # Docker Compose configuration (n8n + Caddy + PostgreSQL)
βββ .env # Environment variables (generated by generate-secrets.sh)
βββ scripts/ # All scripts organized by type
β βββ refresh.sh # π― Main OS-aware refresh script
β βββ generate-secrets.sh # π Cross-platform security & setup script
β βββ cron/ # Cron job management scripts
β βββ install.sh # π― Install/setup cron jobs
β βββ check.sh # π Check cron job status
β βββ test-env.sh # π§ͺ Test cron environment
βββ docs/ # Documentation
β βββ ubuntu-setup-guide.md
β βββ crontab-example.txt
βββ logs/ # Log files (auto-created)
βββ refresh-YYYYMMDD.log
βββ cron-test-YYYYMMDD-HHMMSS.log
- β OS-Aware: Automatically detects macOS vs Ubuntu/Linux
- β Idempotent: Safe to run multiple times
- β Comprehensive: Graceful shutdown, image pull, restart, health checks
- β Logging: Detailed logs with emojis and timestamps
- β Locking: Prevents concurrent runs
- β Resource Monitoring: Disk space and memory checks
- β OS-Aware: Adapts to macOS and Ubuntu environments
- β Idempotent: Safe to run multiple times, removes old jobs
- β Flexible: Daily, weekly, monthly, or custom schedules
- β Prerequisites Check: Validates Docker access and permissions
- β Environment Testing: Tests cron environment compatibility
- β OS-Aware: Automatically detects macOS vs Ubuntu/Linux
- β Comprehensive: Quick status and detailed analysis modes
- β Validation: Checks cron format, script paths, permissions
- β Monitoring: Shows last execution time and cron service status
- β Troubleshooting: Identifies common issues and provides solutions
- β OS-Aware: Automatically detects macOS vs Ubuntu/Linux
- β Comprehensive Testing: Validates Docker access, permissions, and environment
- β Detailed Logging: Creates timestamped logs for troubleshooting
- β Cron Simulation: Tests minimal cron environment compatibility
- β System Validation: Checks disk space, memory, and system requirements
- β Cross-Platform: Works on macOS, Ubuntu/Debian, and CentOS/RHEL
- β Idempotent: Safe to run multiple times without side effects
- β Dependency Checking: Validates required tools and provides install instructions
- β Secure Generation: Creates strong encryption keys and passwords
- β Domain Configuration: Interactive domain setup with automatic TLS configuration
- β Caddy Integration: Configures Caddy reverse proxy with appropriate TLS settings
- β Backup Protection: Creates timestamped backups before regeneration
- β Platform-Specific: Provides OS-specific installation instructions
- β Automatic Docker Desktop detection
- β
User socket permissions (
/Users/username/.docker/run/docker.sock) - β No special group requirements
- β Homebrew PATH support
- β Cross-platform script support
- β System Docker daemon support
- β Docker group membership checks
- β
System socket permissions (
/var/run/docker.sock) - β Systemctl daemon status checks
- β Environment variables for headless operation
- β Cross-platform script support
- β OS-Aware: All scripts automatically detect macOS vs Ubuntu/Linux
- β No Platform-Specific Scripts: Single scripts work on both platforms
- β Automatic Configuration: Platform-specific settings applied automatically
- β Dependency Checking: Validates required tools with platform-specific instructions
- β Fallback Support: Works even without optional dependencies
This homelab setup provides a complete n8n automation platform with:
- n8n: Workflow automation platform with web UI
- Caddy: Modern reverse proxy with automatic HTTPS
- PostgreSQL: Reliable database backend
- Cross-Platform: Works on macOS and Ubuntu/Linux
- Security: Built-in authentication and TLS encryption
- Automation: Automated refresh and monitoring scripts
- n8n Web UI:
https://your-domain.com(orhttps://n8n.localhostfor localhost) - Direct Access:
http://localhost:5678(bypasses reverse proxy)
- π Graceful Shutdown: 30-second timeout for clean container stops
- π₯ Image Updates: Pulls latest versions of all images
- π Service Restart: Starts services in detached mode
- π Health Verification: Waits for services to become healthy
- π Status Reporting: Shows container status and system resources
- π§Ή Log Rotation: Automatically cleans up old log files
- π Process Locking: Prevents multiple instances running
- π Multiple Schedules: Daily, weekly, monthly, custom
- π Idempotent: Removes old jobs before adding new ones
- π§ͺ Environment Testing: Validates cron environment
- π Status Checking: Shows current cron configuration
- π‘οΈ Prerequisites: Validates Docker access and permissions
# Initial setup (first time only)
./scripts/generate-secrets.sh
# Start the platform
docker compose up -d
# Refresh services now
./scripts/refresh.sh
# Set up daily refresh at 2 AM
./scripts/cron/install.sh daily
# Check if cron job is installed
./scripts/cron/check.sh
# Check what's scheduled
./scripts/cron/install.sh status# Custom schedule (every 6 hours)
./scripts/cron/install.sh custom "0 */6 * * *"
# Weekly on Monday at 3 AM
./scripts/cron/install.sh weekly 1
# Monthly on 15th at 4 AM
./scripts/cron/install.sh monthly 15
# Test cron environment
./scripts/cron/install.sh test
# Remove cron job
./scripts/cron/install.sh remove
# Detailed cron job analysis
./scripts/cron/check.sh detailed# Watch logs in real-time
tail -f logs/refresh-$(date +%Y%m%d).log
# Check service status
docker compose ps
# Check service logs
docker compose logs -f# Ubuntu: Add user to docker group
sudo usermod -aG docker $USER
newgrp docker
# Test Docker access
docker ps# Test cron environment
./scripts/cron/install.sh test
# Check cron logs
sudo journalctl -u cron # Ubuntu
log show --predicate 'process == "cron"' --last 1h # macOS# Check service status
docker compose ps
# View service logs
docker compose logs -f
# Restart specific service
docker compose restart service-name
# Check Caddy configuration
docker compose logs caddy
# Test n8n health endpoint
curl -k https://n8n.localhost/healthz# For localhost development, ensure CADDY_TLS=internal in .env
# For production domains, ensure CADDY_TLS is empty in .env
grep CADDY_TLS .env
# Regenerate credentials if needed
./scripts/generate-secrets.sh --force# Check if n8n is running
docker compose ps n8n
# Check n8n logs
docker compose logs n8n
# Test direct access (bypasses reverse proxy)
curl http://localhost:5678/healthz# Check PostgreSQL status
docker compose ps postgres
# Check database logs
docker compose logs postgres
# Test database connection
docker compose exec postgres pg_isready -U n8n_user -d n8nLogs are automatically created in the logs/ directory:
refresh-YYYYMMDD.log- Daily refresh logscron-test-YYYYMMDD-HHMMSS.log- Environment test logs
Log files are automatically rotated after 7 days.
- β n8n Basic Auth: Username/password authentication enabled by default
- β TLS Encryption: Automatic HTTPS with Let's Encrypt (production) or internal certificates (localhost)
- β Secure Cookies: Session management with secure cookie settings
- β Database Security: SCRAM-SHA-256 authentication for PostgreSQL
- β Container Security: Non-root users and no-new-privileges security options
- β Process locking prevents concurrent runs
- β Graceful shutdown with timeout
- β Health verification before completion
- β Resource monitoring and warnings
- β Comprehensive error handling
- β Secure credential generation with strong passwords
- Test on both macOS and Ubuntu
- Ensure scripts are idempotent
- Add appropriate error handling
- Update documentation
- Test cron environment compatibility
This project is part of your homelab setup. Use and modify as needed.