#!/bin/bash # FibDash Nginx Development Setup Script echo "๐Ÿš€ Setting up Nginx for FibDash development..." # Create logs directory mkdir -p logs/nginx # Check if nginx is installed if ! command -v nginx &> /dev/null; then echo "โŒ Nginx is not installed. Please install nginx first:" echo " Ubuntu/Debian: sudo apt-get install nginx" echo " CentOS/RHEL: sudo yum install nginx" echo " macOS: brew install nginx" exit 1 fi # Backup existing nginx configuration if [ -f /etc/nginx/sites-available/default ]; then echo "๐Ÿ“‹ Backing up existing nginx configuration..." sudo cp /etc/nginx/sites-available/default /etc/nginx/sites-available/default.backup.$(date +%Y%m%d_%H%M%S) fi # Copy our nginx configuration echo "๐Ÿ“ Installing FibDash nginx configuration..." sudo cp nginx.dev.conf /etc/nginx/sites-available/fibdash-dev sudo ln -sf /etc/nginx/sites-available/fibdash-dev /etc/nginx/sites-enabled/fibdash-dev # Remove default site if it exists if [ -f /etc/nginx/sites-enabled/default ]; then echo "๐Ÿ—‘๏ธ Removing default nginx site..." sudo rm /etc/nginx/sites-enabled/default fi # Test nginx configuration echo "๐Ÿงช Testing nginx configuration..." sudo nginx -t if [ $? -eq 0 ]; then echo "โœ… Nginx configuration is valid" # Reload nginx echo "๐Ÿ”„ Reloading nginx..." sudo systemctl reload nginx # Enable nginx to start on boot sudo systemctl enable nginx echo "" echo "๐ŸŽ‰ Nginx setup complete!" echo "" echo "๐Ÿ“‹ Setup Summary:" echo " โ€ข Nginx config: /etc/nginx/sites-available/fibdash-dev" echo " โ€ข Logs directory: ./logs/nginx/" echo " โ€ข Frontend (via nginx): http://localhost/" echo " โ€ข API (via nginx): http://localhost/api/" echo " โ€ข Direct frontend: http://localhost:5001/" echo " โ€ข Direct backend: http://localhost:5000/" echo "" echo "๐Ÿš€ Next steps:" echo " 1. Start your development servers: npm run dev" echo " 2. Access your app at: http://localhost/" echo "" echo "๐Ÿ’ก To add fibdash.local to your hosts file:" echo " echo '127.0.0.1 fibdash.local' | sudo tee -a /etc/hosts" else echo "โŒ Nginx configuration test failed. Please check the configuration." exit 1 fi