Files
Church-Music/new-site/DEEP_DEBUG_REPORT.md

197 lines
4.7 KiB
Markdown

# Deep Debugging Summary - January 26, 2026
## Issue Reported
Site not accessible externally with error: "Blocked request. This host ("houseofprayer.ddns.net") is not allowed"
## Root Cause Analysis
### Primary Issue
**Vite Dev Server Host Blocking** - Vite's `allowedHosts` configuration was set to `'all'` but the running frontend process was started before this configuration was applied, causing it to use default restrictive host validation.
### Contributing Factors
1. **Configuration Not Loaded**: Frontend process started with old/default vite.config.js
2. **No Process Restart**: Config changes made but frontend not restarted
3. **Silent Failure**: Vite returned HTTP 403 without clear indication in logs
## Debugging Steps Performed
### 1. Log Analysis
- **Backend logs**: No errors, backend operational on port 8080
- **Nginx error logs**: Showed unrelated ModSecurity warnings from external scanners
- **Frontend logs**: Running but with old configuration
### 2. Service Verification
```bash
# All services confirmed running
- Frontend: Port 5100
- Backend: Port 8080
- Nginx: Port 443
- PostgreSQL: Active ✓
```
### 3. Configuration Review
- **vite.config.js**: Initially had `allowedHosts: 'all'` (not working)
- **server.js**: CORS properly configured for domain
- **nginx-ssl.conf**: Correctly proxying to services
### 4. Host Blocking Test
```bash
curl -H "Host: houseofprayer.ddns.net" http://localhost:5100/
# Result: 403 Forbidden (confirmed host blocking)
```
## Solution Implemented
### Step 1: Updated Vite Configuration
Changed `/frontend/vite.config.js`:
```javascript
server: {
port: 5100,
strictPort: true,
host: true, // Listen on all addresses
allowedHosts: [
".ddns.net", // Wildcard for all .ddns.net subdomains
"houseofprayer.ddns.net", // Specific domain
"localhost",
".localhost",
"192.168.10.130", // Local IP
"127.0.0.1",
],
// ... rest of config
}
```
### Step 2: Restarted Frontend Process
```bash
kill $(lsof -ti:5100)
cd frontend && npm run dev > /tmp/frontend.log 2>&1 &
```
### Step 3: Verified Fix
```bash
curl -H "Host: houseofprayer.ddns.net" http://localhost:5100/
# Result: HTTP 200 OK ✓
```
## Prevention Measures
### 1. Created Health Check Script
Location: `scripts/health-check.sh`
Automatically verifies:
- All services running
- Vite accepts domain (tests host blocking)
- DNS resolution
- Public HTTPS access
- API endpoints responding
Usage:
```bash
./scripts/health-check.sh
```
### 2. Created Startup Checklist
Location: `STARTUP_CHECKLIST.md`
Documents:
- Service verification commands
- Common issues and solutions
- Configuration file locations
- Emergency recovery procedures
- Testing commands
### 3. Configuration Best Practices
**Rule**: Always restart services after config changes
For frontend:
```bash
kill $(lsof -ti:5100)
cd frontend && npm run dev &
```
For backend:
```bash
kill $(lsof -ti:8080)
cd backend && node server.js &
```
## Final Verification
All services operational:
```
✓ Frontend (Vite): Port 5100, accepts houseofprayer.ddns.net
✓ Backend (Node): Port 8080, API responding
✓ Nginx (HTTPS): Port 443, SSL active
✓ PostgreSQL: Database connected
✓ DNS Resolution: houseofprayer.ddns.net → 170.254.17.146
✓ Public Access: https://houseofprayer.ddns.net (200 OK)
```
## Key Learnings
1. **Always restart after config changes** - Configuration files are read at startup, not dynamically
2. **Test host blocking explicitly** - Use curl with Host header to verify
3. **Vite's allowedHosts behavior** - Both `'all'` and array formats work, but require process restart
4. **Health checks are essential** - Automated verification prevents similar issues
## Files Created/Modified
### Created
- `scripts/health-check.sh` - Automated health verification
- `STARTUP_CHECKLIST.md` - Operational documentation
- `DEEP_DEBUG_REPORT.md` - This file
### Modified
- `frontend/vite.config.js` - Fixed allowedHosts configuration
## Recommended Next Steps
1. **Production Build**: Replace Vite dev server with built static files
```bash
cd frontend && npm run build
# Serve from frontend/dist with Nginx
```
2. **Systemd Services**: Create auto-start services for frontend/backend
3. **Monitoring**: Set up uptime monitoring (e.g., UptimeRobot)
4. **Backup Strategy**: Automate database backups
5. **SSL Renewal**: Ensure certbot auto-renewal working
## Time to Resolution
Approximately 15 minutes from issue report to full resolution
## Status
**RESOLVED** - Site fully operational at <https://houseofprayer.ddns.net>
---
**Debugging Session**: January 26, 2026
**Engineer**: GitHub Copilot
**User**: pts
**Site**: House of Prayer Music Database