www_veda_2025/debug_server.sh
2025-08-20 02:16:49 +02:00

90 lines
2.9 KiB
Bash

#!/bin/bash
# VEDA Server Debug Script
# Run this on your production server to diagnose the 404 issues
echo "🔍 VEDA SERVER DEBUGGING"
echo "========================"
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
echo -e "${BLUE}1. Checking Caddy service status...${NC}"
systemctl status caddy --no-pager | head -10
echo ""
echo -e "${BLUE}2. Looking for Caddyfile locations...${NC}"
find /etc -name "Caddyfile" 2>/dev/null || echo "No Caddyfile found in /etc"
find /usr -name "Caddyfile" 2>/dev/null || echo "No Caddyfile found in /usr"
echo ""
echo -e "${BLUE}3. Checking current Caddyfile content...${NC}"
if [ -f "/etc/caddy/Caddyfile" ]; then
echo "Found /etc/caddy/Caddyfile:"
cat /etc/caddy/Caddyfile
elif [ -f "/usr/local/etc/Caddyfile" ]; then
echo "Found /usr/local/etc/Caddyfile:"
cat /usr/local/etc/Caddyfile
else
echo -e "${RED}❌ No Caddyfile found!${NC}"
fi
echo ""
echo -e "${BLUE}4. Checking web directory structure...${NC}"
for dir in "/var/www/veda" "/var/www/veda/out" "/srv/www/veda" "/home/*/public_html" "/var/www/html"; do
if [ -d "$dir" ]; then
echo -e "${GREEN}✅ Found directory: $dir${NC}"
ls -la "$dir" | head -10
echo ""
fi
done
echo -e "${BLUE}5. Checking for key files...${NC}"
for file in "/var/www/veda/out/index.html" "/var/www/veda/out/dahabiyas/index.html" "/var/www/veda/out/story/index.html"; do
if [ -f "$file" ]; then
echo -e "${GREEN}✅ Found: $file${NC}"
else
echo -e "${RED}❌ Missing: $file${NC}"
fi
done
echo ""
echo -e "${BLUE}6. Testing local file access...${NC}"
if [ -f "/var/www/veda/out/dahabiyas/index.html" ]; then
echo "Testing dahabiyas page access:"
head -5 "/var/www/veda/out/dahabiyas/index.html"
else
echo -e "${RED}❌ Cannot access dahabiyas page file${NC}"
fi
echo ""
echo -e "${BLUE}7. Checking Caddy configuration validation...${NC}"
caddy validate --config /etc/caddy/Caddyfile 2>&1 || caddy validate --config /usr/local/etc/Caddyfile 2>&1
echo ""
echo -e "${BLUE}8. Checking Caddy logs...${NC}"
journalctl -u caddy --no-pager -n 20 2>/dev/null || echo "Cannot access Caddy logs"
echo ""
echo -e "${BLUE}9. Testing actual HTTP responses...${NC}"
echo "Testing homepage:"
curl -I http://localhost:80 2>/dev/null | head -3 || echo "Cannot connect to localhost:80"
echo ""
echo "Testing dahabiyas page:"
curl -I http://localhost:80/dahabiyas/ 2>/dev/null | head -3 || echo "Cannot connect to localhost:80/dahabiyas/"
echo ""
echo -e "${YELLOW}=== DEBUGGING COMPLETE ===${NC}"
echo ""
echo -e "${YELLOW}Next steps based on results above:${NC}"
echo "1. If Caddyfile is missing/wrong → Update Caddyfile"
echo "2. If files are missing → Upload 'out' directory contents"
echo "3. If Caddy validation fails → Fix Caddyfile syntax"
echo "4. If Caddy service is down → Restart Caddy service"
echo "5. If files exist but HTTP fails → Check permissions"