# Explorer Final Status and Required Actions

**Date**: January 27, 2025  
**Status**: 🔴 **REQUIRES MANUAL ACTION ON PROXMOX HOST**

---

## 📊 Current Status

### ✅ Working Components
- **Container VMID 5000**: ✅ Running on node pve2
- **Nginx**: ✅ Running and serving frontend (HTTP 200)
- **Ports 80 & 443**: ✅ Open and accessible
- **Direct IP Access**: ✅ http://192.168.11.140 returns frontend

### ❌ Not Working
- **Blockscout Service**: ❌ Not running (port 4000 not accessible)
- **Nginx Proxy to Blockscout**: ❌ Returns 502 Bad Gateway
- **Public URL**: ❌ Returns 404 (Cloudflare routing)

---

## 🎯 Required Action

**The Blockscout service needs to be started manually on the Proxmox host.**

### Quick Fix Command

**SSH to Proxmox host and run:**

```bash
# SSH to Proxmox host
ssh root@192.168.11.10

# Start Blockscout service (container is on pve2)
ssh pve2 'pct exec 5000 -- systemctl start blockscout'

# OR if pve2 hostname doesn't resolve, use IP:
# First find pve2 IP, then:
ssh root@<pve2-ip> 'pct exec 5000 -- systemctl start blockscout'

# Wait 30-60 seconds for Blockscout to start, then verify:
curl http://192.168.11.140:4000/api/v2/status
```

### Alternative: Run Script on Proxmox Host

**Copy and run this script on the Proxmox host:**

```bash
# On Proxmox host (192.168.11.10)
cd /home/intlc/projects/proxmox
bash scripts/start-blockscout-on-proxmox.sh
```

**Or run directly via SSH:**

```bash
# From your current machine
ssh root@192.168.11.10 'bash -s' < /home/intlc/projects/proxmox/scripts/start-blockscout-on-proxmox.sh
```

---

## 🔧 Detailed Steps

### Step 1: Access Proxmox Host

```bash
ssh root@192.168.11.10
```

### Step 2: Find Container Node

```bash
# Check which node has container 5000
for node in ml110 pve pve2; do
    pvesh get /nodes/$node/lxc/5000/status/current --output-format json 2>/dev/null && echo "Found on $node"
done
```

**Expected**: Container is on `pve2`

### Step 3: Access Container Node

**Option A: If pve2 hostname resolves**
```bash
ssh pve2
```

**Option B: If pve2 hostname doesn't resolve, find IP**
```bash
# Get pve2 IP from Proxmox
pvesh get /nodes/pve2 --output-format json | grep -o '"ip":"[^"]*"'
# Then SSH to that IP
ssh root@<pve2-ip>
```

**Option C: Direct from main host (if on cluster)**
```bash
# From main Proxmox host, execute directly
pct exec 5000 -- bash
```

### Step 4: Start Blockscout Service

**Inside container or via pct exec:**

```bash
# Method 1: systemd service
systemctl start blockscout
systemctl enable blockscout
systemctl status blockscout

# Method 2: docker-compose (if systemd doesn't work)
cd /opt/blockscout
docker-compose up -d
# OR
docker compose up -d

# Method 3: Check for existing containers
docker ps -a | grep blockscout
docker start <container-name>
```

### Step 5: Verify Blockscout is Running

```bash
# Check port
ss -tlnp | grep :4000

# Test API
curl http://127.0.0.1:4000/api/v2/status

# Check logs if not working
journalctl -u blockscout -n 50
docker-compose -f /opt/blockscout/docker-compose.yml logs --tail=50
```

### Step 6: Verify External Access

**From your machine:**
```bash
curl http://192.168.11.140:4000/api/v2/status
curl http://192.168.11.140/api/v2/stats
```

**Expected**: Should return JSON with chain_id, not 502 Bad Gateway

### Step 7: Fix Cloudflare (if public URL still 404)

**Check Cloudflare tunnel:**
```bash
# Inside container
systemctl status cloudflared
cat /etc/cloudflared/config.yml
```

**Verify DNS and tunnel route in Cloudflare dashboard**

---

## 📋 Verification Checklist

After starting Blockscout, verify:

- [ ] Container VMID 5000 is running
- [ ] Blockscout service is active: `systemctl status blockscout`
- [ ] Port 4000 is listening: `ss -tlnp | grep :4000`
- [ ] Blockscout API responds: `curl http://127.0.0.1:4000/api/v2/status`
- [ ] External API works: `curl http://192.168.11.140:4000/api/v2/status`
- [ ] Nginx proxy works: `curl http://192.168.11.140/api/v2/stats` (not 502)
- [ ] Public URL works: `curl https://explorer.d-bis.org/api/v2/stats`

---

## 🛠️ Troubleshooting

### Issue: systemctl start blockscout fails

**Check logs:**
```bash
journalctl -u blockscout -n 100
```

**Common causes:**
- PostgreSQL not running
- Missing environment variables
- Docker issues

**Solution:**
```bash
# Check PostgreSQL
docker ps | grep postgres
docker-compose -f /opt/blockscout/docker-compose.yml up -d postgres

# Check environment
cat /opt/blockscout/.env

# Restart all services
cd /opt/blockscout
docker-compose restart
```

### Issue: Port 4000 still not accessible

**Check if Blockscout is actually running:**
```bash
docker ps | grep blockscout
ps aux | grep blockscout
```

**Check firewall:**
```bash
iptables -L -n | grep 4000
ufw status | grep 4000
```

### Issue: Nginx still returns 502

**Verify Nginx config:**
```bash
nginx -t
cat /etc/nginx/sites-available/blockscout | grep proxy_pass
# Should show: proxy_pass http://127.0.0.1:4000;
```

**Restart Nginx:**
```bash
systemctl restart nginx
```

---

## 📝 Scripts Available

All scripts are in `/home/intlc/projects/proxmox/scripts/`:

1. **`diagnose-explorer-status.sh`** - Check current status
2. **`check-blockscout-logs.sh`** - View logs and diagnose issues
3. **`start-blockscout-on-proxmox.sh`** - Start service (run on Proxmox host)
4. **`fix-blockscout-explorer.sh`** - Complete fix script
5. **`restore-explorer-complete.sh`** - Full restoration

---

## ✅ Summary

**Current State**: 
- Container running ✅
- Nginx working ✅  
- Blockscout service stopped ❌

**Action Required**: 
Start Blockscout service on Proxmox host (pve2 node)

**Command**:
```bash
ssh root@192.168.11.10
ssh pve2 'pct exec 5000 -- systemctl start blockscout'
```

**After Starting**: Wait 30-60 seconds, then verify with:
```bash
curl http://192.168.11.140:4000/api/v2/status
```

---

**Last Updated**: January 27, 2025  
**Next Action**: Start Blockscout service on Proxmox host

