Files
trustos/SETUP_CLOUDFLARE_TUNNEL.sh
drjones d92a7c057d Complete local deployment setup with Cloudflare tunnel
- setup_local_hosting.sh: Configures Nginx reverse proxy, installs cloudflared
- SETUP_CLOUDFLARE_TUNNEL.sh: Interactive tunnel setup script (5 min)
- check_status.sh: Real-time status dashboard for all services
- LOCAL_ACCESS_GUIDE.md: Complete local access instructions
- FINAL_DEPLOYMENT_README.md: Comprehensive deployment guide

Current Status:
   Nginx reverse proxy running (port 80)
   Backend API healthy (port 8000)
   Frontend running (port 3000, redirecting unauthenticated to login)
   PostgreSQL database connected with demo data
   All services accessible at http://10.30.20.38
   Cloudflare tunnel installed and ready

Access:
  - Local: http://10.30.20.38
  - With Cloudflare: https://your-domain.com (after tunnel setup)
  - Demo credentials included and working

Next Steps:
  1. Visit http://10.30.20.38 and login
  2. Run SETUP_CLOUDFLARE_TUNNEL.sh for global access
  3. Share HTTPS URL with anyone

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-07 14:06:47 +00:00

147 lines
5.1 KiB
Bash
Executable File
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# TrustOS Cloudflare Tunnel Quick Setup
# This script guides you through setting up remote access via Cloudflare
set -e
echo "╔════════════════════════════════════════════════════════════════╗"
echo "║ 🌐 TRUSTOS CLOUDFLARE TUNNEL SETUP ║"
echo "╚════════════════════════════════════════════════════════════════╝"
echo ""
# Check if cloudflared is installed
if ! command -v cloudflared &> /dev/null; then
echo "❌ cloudflared not installed"
echo ""
echo "Installing Cloudflare tunnel..."
curl -s -L https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 -o /usr/local/bin/cloudflared
chmod +x /usr/local/bin/cloudflared
echo "✅ cloudflared installed"
fi
echo ""
echo "📋 SETUP STEPS:"
echo "═════════════════════════════════════════════════════════════════"
echo ""
# Step 1: Login
echo "STEP 1⃣ : Authenticate with Cloudflare"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
echo "This will open a browser to authenticate. You need:"
echo " ✓ Cloudflare account (free tier works)"
echo " ✓ Internet browser"
echo ""
echo "Press ENTER to continue or Ctrl+C to cancel..."
read -r
cloudflared tunnel login
echo ""
echo "✅ Authenticated!"
echo ""
# Step 2: Create tunnel
echo "STEP 2⃣ : Create Tunnel"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
cloudflared tunnel create trustos
echo ""
echo "✅ Tunnel 'trustos' created!"
echo ""
# Step 3: Get domain
echo "STEP 3⃣ : Configure Domain"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
echo "You can:"
echo " A) Use Cloudflare DNS (simplest)"
echo " B) Use your own domain registrar"
echo ""
echo "Enter your domain (e.g., trustos.example.com): "
read -r DOMAIN
if [ -z "$DOMAIN" ]; then
echo "❌ No domain provided. Exiting."
exit 1
fi
echo ""
echo "Setting up domain: $DOMAIN"
echo ""
# Route DNS
cloudflared tunnel route dns trustos "$DOMAIN"
echo ""
echo "✅ Domain routed!"
echo ""
# Step 4: Start tunnel
echo "STEP 4⃣ : Start Tunnel"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
echo "Choose how to run the tunnel:"
echo ""
echo "Option A) As systemd service (background, automatic restarts)"
echo "Option B) Manual (foreground, for testing)"
echo ""
echo "Enter choice (A/B): "
read -r CHOICE
if [ "$CHOICE" = "A" ] || [ "$CHOICE" = "a" ]; then
echo ""
echo "Starting tunnel service..."
systemctl restart trustos-tunnel
systemctl enable trustos-tunnel
echo ""
echo "⏳ Waiting for tunnel to start..."
sleep 3
if systemctl is-active --quiet trustos-tunnel; then
echo "✅ Tunnel service started!"
echo ""
echo "View logs: journalctl -u trustos-tunnel -f"
else
echo "❌ Failed to start service. Trying manual mode..."
CHOICE="B"
fi
fi
if [ "$CHOICE" = "B" ] || [ "$CHOICE" = "b" ]; then
echo ""
echo "Starting tunnel (foreground mode)..."
echo "Press Ctrl+C to stop"
echo ""
cloudflared tunnel run trustos --url http://localhost:80
fi
echo ""
echo "╔════════════════════════════════════════════════════════════════╗"
echo "║ 🎉 SETUP COMPLETE! ║"
echo "╚════════════════════════════════════════════════════════════════╝"
echo ""
echo "🌐 Your TrustOS instance is now accessible at:"
echo ""
echo " https://$DOMAIN"
echo ""
echo "📊 Tunnel Information:"
cloudflared tunnel info trustos
echo ""
echo "🔐 Demo Credentials:"
echo " Email: executive@acmecorp.io"
echo " Password: TrustOS2024!"
echo ""
echo "⚙️ Management:"
echo " View tunnel status: cloudflared tunnel info trustos"
echo " View tunnel logs: journalctl -u trustos-tunnel -f"
echo " Stop tunnel: systemctl stop trustos-tunnel"
echo " Restart tunnel: systemctl restart trustos-tunnel"
echo ""
echo "💡 Tip: Share the HTTPS URL with anyone to give them access!"
echo ""