#cloud-config # Mailcow VM - Ubuntu 24.04 # VM 201 | IP: 10.48.200.82 # Hostname: mail.web.orbishosting.com package_update: true package_upgrade: true packages: - curl - ca-certificates - git - htop - net-tools - nftables - qemu-guest-agent runcmd: # Enable and start qemu-guest-agent - systemctl enable qemu-guest-agent - systemctl start qemu-guest-agent # Set hostname (Mailcow requires this to match MAILCOW_HOSTNAME) - hostnamectl set-hostname mail.web.orbishosting.com - echo "127.0.0.1 mail.web.orbishosting.com mail" >> /etc/hosts # Install Docker - curl -fsSL https://get.docker.com | sh - systemctl enable docker - usermod -aG docker ubuntu # Install Mailcow - git clone https://github.com/mailcow/mailcow-dockerized /opt/mailcow-dockerized # Generate Mailcow config non-interactively - | cd /opt/mailcow-dockerized MAILCOW_HOSTNAME=mail.web.orbishosting.com \ MAILCOW_TZ=America/New_York \ ./generate_config.sh # Configure Mailcow to run behind NPM reverse proxy # HTTP on 8080 (proxied by NPM), HTTPS bound only to localhost - | sed -i 's/^HTTP_PORT=.*/HTTP_PORT=8080/' /opt/mailcow-dockerized/mailcow.conf sed -i 's/^HTTP_BIND=.*/HTTP_BIND=0.0.0.0/' /opt/mailcow-dockerized/mailcow.conf sed -i 's/^HTTPS_PORT=.*/HTTPS_PORT=8443/' /opt/mailcow-dockerized/mailcow.conf sed -i 's/^HTTPS_BIND=.*/HTTPS_BIND=127.0.0.1/' /opt/mailcow-dockerized/mailcow.conf # Pull images and start Mailcow - cd /opt/mailcow-dockerized && docker compose pull - cd /opt/mailcow-dockerized && docker compose up -d # Add Mailcow startup service - | cat > /etc/systemd/system/mailcow.service << 'SERVICE' [Unit] Description=Mailcow Email Server After=docker.service Requires=docker.service [Service] Type=oneshot RemainAfterExit=yes WorkingDirectory=/opt/mailcow-dockerized ExecStart=/usr/bin/docker compose up -d ExecStop=/usr/bin/docker compose down TimeoutStartSec=0 [Install] WantedBy=multi-user.target SERVICE - systemctl enable mailcow.service final_message: | Mailcow VM is ready. Web UI accessible internally at: http://10.48.200.82:8080 Default admin: admin / moohoo CHANGE THE PASSWORD IMMEDIATELY after DNS and NPM proxy are configured.