#!/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 "================================================"