Fix jwt-token
This commit is contained in:
71
scripts/setup-nginx.sh
Normal file
71
scripts/setup-nginx.sh
Normal file
@@ -0,0 +1,71 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Drone Detection System - Nginx Setup Script
|
||||
# This script sets up the Nginx configuration for the drone detection system
|
||||
|
||||
set -e
|
||||
|
||||
echo "🚁 Setting up Nginx configuration for Drone Detection System..."
|
||||
|
||||
# Configuration variables
|
||||
NGINX_CONFIG_FILE="drones.cqers.com"
|
||||
SITES_AVAILABLE="/etc/nginx/sites-available"
|
||||
SITES_ENABLED="/etc/nginx/sites-enabled"
|
||||
DOMAIN="drones.cqers.com"
|
||||
|
||||
# Check if running as root
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
echo "❌ This script must be run as root (use sudo)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if nginx is installed
|
||||
if ! command -v nginx &> /dev/null; then
|
||||
echo "❌ Nginx is not installed. Please install nginx first:"
|
||||
echo " sudo apt update && sudo apt install nginx"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Copy the configuration file
|
||||
echo "📋 Copying nginx configuration..."
|
||||
cp nginx/$NGINX_CONFIG_FILE $SITES_AVAILABLE/
|
||||
|
||||
# Create symlink to enable the site
|
||||
echo "🔗 Enabling the site..."
|
||||
ln -sf $SITES_AVAILABLE/$NGINX_CONFIG_FILE $SITES_ENABLED/
|
||||
|
||||
# Test nginx configuration
|
||||
echo "🔍 Testing nginx configuration..."
|
||||
if nginx -t; then
|
||||
echo "✅ Nginx configuration is valid"
|
||||
else
|
||||
echo "❌ Nginx configuration has errors"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Reload nginx
|
||||
echo "🔄 Reloading nginx..."
|
||||
systemctl reload nginx
|
||||
|
||||
echo ""
|
||||
echo "🎉 Nginx configuration setup complete!"
|
||||
echo "================================================"
|
||||
echo "Your drone detection system is now available at:"
|
||||
echo "🌐 HTTP: http://$DOMAIN"
|
||||
echo "🔒 HTTPS: https://$DOMAIN (if SSL configured)"
|
||||
echo ""
|
||||
echo "Local access URLs:"
|
||||
echo "🌐 HTTP: http://localhost"
|
||||
echo "📊 API: http://localhost/api"
|
||||
echo "💚 Health: http://localhost/health"
|
||||
echo ""
|
||||
echo "Next steps:"
|
||||
echo "1. Make sure your Docker containers are running:"
|
||||
echo " docker-compose up -d"
|
||||
echo ""
|
||||
echo "2. Test the endpoints:"
|
||||
echo " curl http://localhost/health"
|
||||
echo " curl http://localhost/api/health"
|
||||
echo ""
|
||||
echo "3. (Optional) Configure SSL certificates for HTTPS"
|
||||
echo "================================================"
|
||||
104
scripts/troubleshoot.sh
Normal file
104
scripts/troubleshoot.sh
Normal file
@@ -0,0 +1,104 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Drone Detection System - Troubleshooting Script
|
||||
# This script helps diagnose common issues with the drone detection system
|
||||
|
||||
echo "🔧 Drone Detection System - Troubleshooting"
|
||||
echo "============================================"
|
||||
|
||||
# Check Docker status
|
||||
echo ""
|
||||
echo "📋 Checking Docker containers..."
|
||||
if command -v docker &> /dev/null; then
|
||||
docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"
|
||||
echo ""
|
||||
|
||||
# Check specific containers
|
||||
echo "🔍 Checking drone detection containers..."
|
||||
if docker ps | grep -q "drone-detection"; then
|
||||
echo "✅ Drone detection containers are running"
|
||||
else
|
||||
echo "❌ Drone detection containers not found. Run: docker-compose up -d"
|
||||
fi
|
||||
else
|
||||
echo "❌ Docker is not installed or not running"
|
||||
fi
|
||||
|
||||
# Check port availability
|
||||
echo ""
|
||||
echo "🌐 Checking port availability..."
|
||||
ports=(3001 3002 5433 6380)
|
||||
for port in "${ports[@]}"; do
|
||||
if ss -tulpn | grep -q ":$port "; then
|
||||
echo "✅ Port $port is in use"
|
||||
else
|
||||
echo "⚠️ Port $port is not in use"
|
||||
fi
|
||||
done
|
||||
|
||||
# Check Nginx status
|
||||
echo ""
|
||||
echo "🌍 Checking Nginx status..."
|
||||
if command -v nginx &> /dev/null; then
|
||||
if systemctl is-active --quiet nginx; then
|
||||
echo "✅ Nginx is running"
|
||||
else
|
||||
echo "❌ Nginx is not running. Start with: sudo systemctl start nginx"
|
||||
fi
|
||||
|
||||
# Check nginx configuration
|
||||
if nginx -t &>/dev/null; then
|
||||
echo "✅ Nginx configuration is valid"
|
||||
else
|
||||
echo "❌ Nginx configuration has errors. Check with: sudo nginx -t"
|
||||
fi
|
||||
else
|
||||
echo "❌ Nginx is not installed"
|
||||
fi
|
||||
|
||||
# Check site configuration
|
||||
echo ""
|
||||
echo "📄 Checking site configuration..."
|
||||
if [ -f "/etc/nginx/sites-enabled/drones.cqers.com" ]; then
|
||||
echo "✅ Drone detection nginx config is enabled"
|
||||
else
|
||||
echo "❌ Drone detection nginx config not found"
|
||||
echo " Run the setup script: sudo ./scripts/setup-nginx.sh"
|
||||
fi
|
||||
|
||||
# Test endpoints
|
||||
echo ""
|
||||
echo "🔗 Testing endpoints..."
|
||||
endpoints=(
|
||||
"http://localhost:3001"
|
||||
"http://localhost:3002/health"
|
||||
"http://localhost/health"
|
||||
)
|
||||
|
||||
for endpoint in "${endpoints[@]}"; do
|
||||
if curl -s -f "$endpoint" >/dev/null; then
|
||||
echo "✅ $endpoint is responding"
|
||||
else
|
||||
echo "❌ $endpoint is not responding"
|
||||
fi
|
||||
done
|
||||
|
||||
# Check logs
|
||||
echo ""
|
||||
echo "📊 Recent Docker logs (last 10 lines)..."
|
||||
if command -v docker &> /dev/null; then
|
||||
echo "--- Backend logs ---"
|
||||
docker logs --tail 10 drone-detection-backend 2>/dev/null || echo "No backend container logs"
|
||||
echo ""
|
||||
echo "--- Frontend logs ---"
|
||||
docker logs --tail 10 drone-detection-frontend 2>/dev/null || echo "No frontend container logs"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "🏁 Troubleshooting complete!"
|
||||
echo ""
|
||||
echo "Common solutions:"
|
||||
echo "1. Restart containers: docker-compose restart"
|
||||
echo "2. Rebuild containers: docker-compose up -d --build"
|
||||
echo "3. Check logs: docker-compose logs -f"
|
||||
echo "4. Reload nginx: sudo systemctl reload nginx"
|
||||
Reference in New Issue
Block a user