#!/bin/bash set -e echo "==========================================" echo "SELF-HOSTED SETUP — No Cloudflare" echo "==========================================" # 1. Check if running as root or with sudo if [ "$EUID" -ne 0 ]; then echo "Note: Some operations may require sudo" fi # 2. Install nginx if not present if ! command -v nginx &> /dev/null; then echo "Installing nginx..." if command -v apt-get &> /dev/null; then sudo apt-get update sudo apt-get install -y nginx elif command -v dnf &> /dev/null; then sudo dnf install -y nginx elif command -v yum &> /dev/null; then sudo yum install -y nginx else echo "Could not install nginx automatically" exit 1 fi fi # 3. Copy nginx config echo "Setting up nginx configuration..." sudo cp /home/bernt/.openclaw/workspace/iom/nginx/selfhosted.conf /etc/nginx/sites-available/iom-api sudo ln -sf /etc/nginx/sites-available/iom-api /etc/nginx/sites-enabled/iom-api # 4. Remove default site sudo rm -f /etc/nginx/sites-enabled/default # 5. Test nginx config echo "Testing nginx configuration..." sudo nginx -t # 6. Start/restart nginx echo "Starting nginx..." sudo systemctl restart nginx sudo systemctl enable nginx # 7. Check if API is running echo "Checking API..." if ! curl -s -k https://localhost:8000/health | grep -q "healthy"; then echo "API not running. Starting..." cd /home/bernt/.openclaw/workspace/iom python3 -m uvicorn api.main:app --host 0.0.0.0 --port 8000 --ssl-keyfile ssl/server.key --ssl-certfile ssl/server.crt & sleep 5 fi # 8. Test endpoints echo "" echo "Testing endpoints..." # Test localhost echo -n "localhost:8000: " if curl -s -k https://localhost:8000/health | grep -q "healthy"; then echo "✓ OK" else echo "✗ FAIL" fi # Test nginx (if domains are configured) echo -n "nginx proxy: " if curl -s -k https://localhost/health 2>/dev/null | grep -q "healthy"; then echo "✓ OK" else echo "✗ FAIL (expected if domains not configured)" fi # 9. DNS configuration info echo "" echo "==========================================" echo "DNS CONFIGURATION REQUIRED" echo "==========================================" echo "" echo "Since you're self-hosted without Cloudflare," echo "configure DNS records to point to this server:" echo "" echo "A RECORDS:" echo " api.quixzoom.com → $(curl -s ifconfig.me 2>/dev/null || echo 'YOUR_SERVER_IP')" echo " api.landvex.com → $(curl -s ifconfig.me 2>/dev/null || echo 'YOUR_SERVER_IP')" echo "" echo "If using AWS Route 53:" echo " 1. Go to Route 53 console" echo " 2. Create/update hosted zone" echo " 3. Add A records pointing to EC2 instance IP" echo "" echo "If testing locally, add to /etc/hosts:" echo " 127.0.0.1 api.quixzoom.com api.landvex.com" echo "" echo "==========================================" echo "SETUP COMPLETE" echo "=========================================="