#!/usr/bin/env bash # Add a domain + HTTPS (Let's Encrypt) to the MoonBite Dashboard on the VPS. # Run as root AFTER setup-dashboard.sh. Requires the domain's DNS to already # point at this server's public IP. # # Usage: # DOMAIN=your.domain.tld ./setup-https.sh # # Default domain uses sslip.io (a free wildcard DNS that maps # .sslip.io -> with no signup). Replace with your own domain # by exporting DOMAIN before running. set -euo pipefail DOMAIN="${DOMAIN:?export DOMAIN=your-domain.example (or .sslip.io) before running}" # Also cover the www host when the domain is an apex (has exactly one dot). WWW="" if [ "$(echo "$DOMAIN" | tr -cd '.' | wc -c)" = "1" ]; then WWW="www.$DOMAIN" fi echo "=== 1/4 Install certbot ===" DEBIAN_FRONTEND=noninteractive apt-get install -y -qq certbot python3-certbot-nginx > /dev/null echo "=== 2/4 Point nginx at the domain ===" cat > /etc/nginx/sites-available/moonbite-dashboard </dev/null || true nginx -t && systemctl reload nginx echo "" echo "=== DONE ===" echo "Dashboard live at: https://$DOMAIN" [ -n "$WWW" ] && echo " (also covers https://$WWW)"