91 lines
2.9 KiB
Bash
Executable File
91 lines
2.9 KiB
Bash
Executable File
#!/bin/bash
|
||
|
||
echo "🌐 Deploying Tilbudsgiveren with Proxy Architecture"
|
||
echo "=================================================="
|
||
echo "Architecture: Internet -> 192.168.1.23 (nginx) -> 192.168.1.24 (app)"
|
||
echo ""
|
||
|
||
# Colors
|
||
RED='\033[0;31m'
|
||
GREEN='\033[0;32m'
|
||
YELLOW='\033[1;33m'
|
||
NC='\033[0m'
|
||
|
||
error() { echo -e "${RED}❌ ERROR: $1${NC}"; exit 1; }
|
||
success() { echo -e "${GREEN}✅ $1${NC}"; }
|
||
info() { echo -e "ℹ️ $1"; }
|
||
|
||
# Step 1: Ensure app server is running on 192.168.1.24
|
||
info "Step 1: Checking application server on 192.168.1.24..."
|
||
if curl -s http://192.168.1.24:4031/api/health > /dev/null; then
|
||
success "Application server is running on port 4031"
|
||
else
|
||
error "Application server not responding on 192.168.1.24:4031"
|
||
fi
|
||
|
||
# Step 2: Test proxy server connectivity
|
||
info "Step 2: Testing connectivity to proxy server..."
|
||
if ping -c 1 192.168.1.23 > /dev/null 2>&1; then
|
||
success "Proxy server 192.168.1.23 is reachable"
|
||
else
|
||
error "Cannot reach proxy server at 192.168.1.23"
|
||
fi
|
||
|
||
# Step 3: Deploy nginx config to proxy server (requires SSH key setup)
|
||
info "Step 3: Deploying nginx configuration to proxy server..."
|
||
echo "⚠️ Manual steps required on 192.168.1.23:"
|
||
echo ""
|
||
echo "1. SSH to proxy server:"
|
||
echo " ssh alex@192.168.1.23"
|
||
echo ""
|
||
echo "2. Create nginx config:"
|
||
echo " sudo nano /etc/nginx/sites-available/tilbudsgiveren.alw.dk"
|
||
echo ""
|
||
echo "3. Add this configuration:"
|
||
echo " (Copy content from /data/tilbudgivern/nginx-proxy-config-for-23.conf)"
|
||
echo ""
|
||
echo "4. Enable site:"
|
||
echo " sudo ln -sf /etc/nginx/sites-available/tilbudsgiveren.alw.dk /etc/nginx/sites-enabled/"
|
||
echo ""
|
||
echo "5. Test and reload nginx:"
|
||
echo " sudo nginx -t && sudo systemctl reload nginx"
|
||
echo ""
|
||
|
||
# Step 4: Show current config for easy copying
|
||
info "Step 4: Current proxy configuration (copy this to 192.168.1.23):"
|
||
echo "=================================================="
|
||
cat /data/tilbudgivern/nginx-proxy-config-for-23.conf
|
||
echo "=================================================="
|
||
echo ""
|
||
|
||
# Step 5: Test local setup first
|
||
info "Step 5: Final tests on this machine (192.168.1.24)..."
|
||
|
||
# Test backend directly
|
||
if curl -s http://localhost:4031/api/health | grep -q "ok"; then
|
||
success "Backend API health check passed"
|
||
else
|
||
error "Backend API health check failed"
|
||
fi
|
||
|
||
# Test material packages
|
||
if curl -s http://localhost:4031/api/material-packages | grep -q "success"; then
|
||
success "Material packages API working"
|
||
else
|
||
error "Material packages API failed"
|
||
fi
|
||
|
||
# Show PM2 status
|
||
info "PM2 Status:"
|
||
pm2 status
|
||
|
||
echo ""
|
||
success "Local deployment complete!"
|
||
echo ""
|
||
echo "🔄 Next steps:"
|
||
echo " 1. Apply the nginx config on 192.168.1.23 (see manual steps above)"
|
||
echo " 2. Test: curl -I http://192.168.1.23/api/health"
|
||
echo " 3. If working locally, test: https://tilbudsgiveren.alw.dk/api/health"
|
||
echo ""
|
||
echo "🌐 When proxy is configured, app will be available at:"
|
||
echo " https://tilbudsgiveren.alw.dk" |