# Frontend Deployment Fix

## Problem
The explorer at `https://explorer.d-bis.org/` shows "Page not found" because:
1. Nginx is proxying to Blockscout (port 4000) which serves its own UI
2. The custom frontend (`explorer-monorepo/frontend/public/index.html`) is not deployed to `/var/www/html/` on VMID 5000

## Solution

### Step 1: Update Nginx Configuration
Update nginx to serve the custom frontend from `/var/www/html/` instead of proxying everything to Blockscout.

**Run in VMID 5000:**
```bash
# Option 1: Use the fix script
cd /home/intlc/projects/proxmox/explorer-monorepo
bash scripts/fix-nginx-serve-custom-frontend.sh

# Option 2: Run commands directly
bash scripts/fix-nginx-serve-custom-frontend.sh
```

This script will:
- Backup current nginx config
- Update nginx to serve custom frontend from `/var/www/html/`
- Keep API proxying to Blockscout on port 4000
- Handle SSL certificates (create self-signed if Let's Encrypt not available)
- Test and restart nginx

### Step 2: Deploy Custom Frontend
Deploy the custom frontend to `/var/www/html/index.html`:

**From Proxmox host:**
```bash
cd /home/intlc/projects/proxmox/explorer-monorepo
bash scripts/deploy-frontend-to-vmid5000.sh
```

**Or manually from VMID 5000:**
```bash
# If you have access to the repo in VMID 5000
cp /home/intlc/projects/proxmox/explorer-monorepo/frontend/public/index.html /var/www/html/index.html
chown www-data:www-data /var/www/html/index.html
```

**Or using SSH from Proxmox host:**
```bash
# Using existing deploy script
cd /home/intlc/projects/proxmox/explorer-monorepo
PASSWORD="L@kers2010" bash scripts/deploy.sh
```

### Step 3: Verify
```bash
# Check if frontend file exists
ls -la /var/www/html/index.html

# Test HTTP endpoint
curl -s http://localhost/ | head -10

# Test HTTPS endpoint (if accessible)
curl -k -s https://localhost/ | head -10

# Check nginx logs
tail -f /var/log/nginx/blockscout-access.log
tail -f /var/log/nginx/blockscout-error.log
```

## Nginx Configuration Details

The updated nginx config:
- **Root path (`/`)**: Serves custom frontend from `/var/www/html/index.html`
- **API path (`/api/`)**: Proxies to Blockscout on port 4000
- **Static assets**: Served from `/var/www/html/` with caching
- **Blockscout UI**: Available at `/blockscout/` if needed

## Troubleshooting

### Frontend still shows "Page not found"
1. Check if file exists: `ls -la /var/www/html/index.html`
2. Check file permissions: `chown www-data:www-data /var/www/html/index.html`
3. Check nginx config: `nginx -t`
4. Check nginx error logs: `tail -20 /var/log/nginx/blockscout-error.log`

### Nginx config errors
1. Restore backup: `cp /etc/nginx/sites-available/blockscout.backup.* /etc/nginx/sites-available/blockscout`
2. Test config: `nginx -t`
3. Check syntax: `cat /etc/nginx/sites-available/blockscout`

### Frontend not updating
1. Clear browser cache (hard refresh: Ctrl+Shift+R)
2. Check if file was updated: `stat /var/www/html/index.html`
3. Reload nginx: `systemctl reload nginx`

## Files Modified
- `/etc/nginx/sites-available/blockscout` - Nginx configuration
- `/var/www/html/index.html` - Custom frontend (needs to be deployed)

