#!/bin/bash # Nginx Proxy Cache Clear Script # Run this on your NGINX PROXY LXC (not the backend LXC!) echo "๐Ÿงน LuckyChit - Nginx Proxy Cache Clear" echo "======================================" echo "" # Check if running as root if [ "$EUID" -ne 0 ]; then echo "โš ๏ธ This script needs sudo privileges" echo "Run with: sudo ./nginx-clear-cache.sh" exit 1 fi echo "๐Ÿ“Š Step 1/5: Checking nginx status..." systemctl status nginx --no-pager | head -n 3 echo "" echo "๐Ÿ” Step 2/5: Finding nginx cache directories..." CACHE_DIRS=$(find /var -name "*cache*" -type d 2>/dev/null | grep nginx) if [ -z "$CACHE_DIRS" ]; then echo "No nginx cache directories found" else echo "Found cache directories:" echo "$CACHE_DIRS" fi echo "" echo "๐Ÿ—‘๏ธ Step 3/5: Clearing nginx cache..." # Clear common cache locations rm -rf /var/cache/nginx/* 2>/dev/null && echo "โœ… Cleared /var/cache/nginx/" || echo "โš ๏ธ /var/cache/nginx/ not found" rm -rf /var/lib/nginx/cache/* 2>/dev/null && echo "โœ… Cleared /var/lib/nginx/cache/" || echo "โš ๏ธ /var/lib/nginx/cache/ not found" rm -rf /var/run/nginx-cache/* 2>/dev/null && echo "โœ… Cleared /var/run/nginx-cache/" || echo "โš ๏ธ /var/run/nginx-cache/ not found" rm -rf /tmp/nginx/* 2>/dev/null && echo "โœ… Cleared /tmp/nginx/" || echo "โš ๏ธ /tmp/nginx/ not found" echo "" echo "โœ… Step 4/5: Testing nginx configuration..." nginx -t if [ $? -eq 0 ]; then echo "" echo "โ™ป๏ธ Step 5/5: Reloading nginx..." systemctl reload nginx if [ $? -eq 0 ]; then echo "โœ… Nginx reloaded successfully!" else echo "โŒ Failed to reload nginx" echo "Try: systemctl restart nginx" exit 1 fi else echo "โŒ Nginx configuration has errors!" echo "Fix configuration before reloading" exit 1 fi echo "" echo "โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”" echo "๐Ÿงช Testing Backend Connectivity" echo "โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”" # Test backend connectivity echo "" echo "Testing backend (192.168.8.148:3000)..." BACKEND_RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" http://192.168.8.148:3000/health 2>/dev/null) if [ "$BACKEND_RESPONSE" = "200" ]; then echo "โœ… Backend API responding: HTTP $BACKEND_RESPONSE" else echo "โŒ Backend API not responding: HTTP $BACKEND_RESPONSE" echo " Check if PM2 is running on backend LXC" fi echo "" echo "Testing frontend (192.168.8.148:8080)..." FRONTEND_RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" http://192.168.8.148:8080 2>/dev/null) if [ "$FRONTEND_RESPONSE" = "200" ]; then echo "โœ… Frontend responding: HTTP $FRONTEND_RESPONSE" else echo "โŒ Frontend not responding: HTTP $FRONTEND_RESPONSE" echo " Check if PM2 is running on backend LXC" fi echo "" echo "โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”" echo "โœ… Cache clearing complete!" echo "โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”" echo "" echo "๐ŸŒ Now test your site:" echo " https://chitfund.deepteklabs.com" echo "" echo "๐Ÿ’ก Don't forget to hard refresh in browser:" echo " Windows: Ctrl + Shift + R" echo " Mac: Cmd + Shift + R" echo ""