Integrate self-hosted Supabase with mem0 system
- Configure mem0 to use self-hosted Supabase instead of Qdrant for vector storage - Update docker-compose to connect containers to localai network - Install vecs library for Supabase pgvector integration - Create comprehensive test suite for Supabase + mem0 integration - Update documentation to reflect Supabase configuration - All containers now connected to shared localai network - Successful vector storage and retrieval tests completed 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
220
FIX_502_ERROR.md
Normal file
220
FIX_502_ERROR.md
Normal file
@@ -0,0 +1,220 @@
|
||||
# Fix 502 Error for docs.klas.chat
|
||||
|
||||
## 🔍 Root Cause Analysis
|
||||
|
||||
The 502 error on docs.klas.chat is caused by two issues:
|
||||
|
||||
1. **Caddyfile Syntax Error**: Line 276 has incorrect indentation
|
||||
2. **Mintlify Server Not Running**: The target port is not bound
|
||||
|
||||
## 🛠️ Issue 1: Fix Caddyfile Syntax Error
|
||||
|
||||
**Problem**: Line 276 in `/etc/caddy/Caddyfile` has incorrect indentation:
|
||||
```
|
||||
encode gzip # ❌ Wrong - uses spaces
|
||||
```
|
||||
|
||||
**Solution**: Fix the indentation to use a TAB character:
|
||||
```bash
|
||||
sudo nano /etc/caddy/Caddyfile
|
||||
```
|
||||
|
||||
Change line 276 from:
|
||||
```
|
||||
encode gzip
|
||||
```
|
||||
to:
|
||||
```
|
||||
encode gzip
|
||||
```
|
||||
(Use TAB character for indentation, not spaces)
|
||||
|
||||
## 🚀 Issue 2: Start Mintlify Server
|
||||
|
||||
**Problem**: No service is running on the target port.
|
||||
|
||||
**Solution**: Start Mintlify on a free port:
|
||||
|
||||
### Option A: Use Port 3005 (Recommended)
|
||||
|
||||
1. **Update Caddyfile** to use port 3005:
|
||||
```bash
|
||||
sudo nano /etc/caddy/Caddyfile
|
||||
```
|
||||
|
||||
Change line 275 from:
|
||||
```
|
||||
reverse_proxy localhost:3003
|
||||
```
|
||||
to:
|
||||
```
|
||||
reverse_proxy localhost:3005
|
||||
```
|
||||
|
||||
2. **Start Mintlify on port 3005**:
|
||||
```bash
|
||||
cd /home/klas/mem0/docs
|
||||
mint dev --port 3005
|
||||
```
|
||||
|
||||
3. **Reload Caddy**:
|
||||
```bash
|
||||
sudo systemctl reload caddy
|
||||
```
|
||||
|
||||
### Option B: Use Port 3010 (Alternative)
|
||||
|
||||
If port 3005 is also occupied:
|
||||
|
||||
1. **Update Caddyfile** to use port 3010
|
||||
2. **Start Mintlify**:
|
||||
```bash
|
||||
cd /home/klas/mem0/docs
|
||||
mint dev --port 3010
|
||||
```
|
||||
|
||||
## 📋 Complete Fix Process
|
||||
|
||||
Here's the complete step-by-step process:
|
||||
|
||||
### Step 1: Fix Caddyfile Syntax
|
||||
```bash
|
||||
# Open Caddyfile in editor
|
||||
sudo nano /etc/caddy/Caddyfile
|
||||
|
||||
# Find the docs.klas.chat section (around line 267)
|
||||
# Fix line 276: change " encode gzip" to " encode gzip" (use TAB)
|
||||
# Change line 275: "reverse_proxy localhost:3003" to "reverse_proxy localhost:3005"
|
||||
```
|
||||
|
||||
**Corrected docs.klas.chat section should look like:**
|
||||
```
|
||||
docs.klas.chat {
|
||||
tls /certs/klas.chat/fullchain.cer /certs/klas.chat/klas.chat.key
|
||||
|
||||
# Basic Authentication
|
||||
basicauth * {
|
||||
langmem $2a$14$.1fx02QwkkmfezhZMLE4Iu2N/ub5vwDSAtcH9lAa5z11ChjiYy1PG
|
||||
}
|
||||
|
||||
reverse_proxy localhost:3005
|
||||
encode gzip
|
||||
}
|
||||
```
|
||||
|
||||
### Step 2: Validate and Reload Caddy
|
||||
```bash
|
||||
# Validate Caddyfile syntax
|
||||
sudo caddy validate --config /etc/caddy/Caddyfile
|
||||
|
||||
# If validation passes, reload Caddy
|
||||
sudo systemctl reload caddy
|
||||
```
|
||||
|
||||
### Step 3: Start Mintlify Server
|
||||
```bash
|
||||
cd /home/klas/mem0/docs
|
||||
mint dev --port 3005
|
||||
```
|
||||
|
||||
### Step 4: Test the Fix
|
||||
```bash
|
||||
# Test direct connection to Mintlify
|
||||
curl -I localhost:3005
|
||||
|
||||
# Test through Caddy proxy (should work after authentication)
|
||||
curl -I -k https://docs.klas.chat
|
||||
```
|
||||
|
||||
## 🔍 Port Usage Analysis
|
||||
|
||||
Current occupied ports in the 3000 range:
|
||||
- **3000**: Next.js server (PID 394563)
|
||||
- **3001**: Unknown service
|
||||
- **3002**: Unknown service
|
||||
- **3003**: Not actually bound (Mintlify failed to start)
|
||||
- **3005**: Available ✅
|
||||
|
||||
## 🆘 Troubleshooting
|
||||
|
||||
### If Mintlify Won't Start
|
||||
```bash
|
||||
# Check for Node.js issues
|
||||
node --version
|
||||
npm --version
|
||||
|
||||
# Update Mintlify if needed
|
||||
npm update -g mint
|
||||
|
||||
# Try a different port
|
||||
mint dev --port 3010
|
||||
```
|
||||
|
||||
### If Caddy Won't Reload
|
||||
```bash
|
||||
# Check Caddy status
|
||||
sudo systemctl status caddy
|
||||
|
||||
# Check Caddy logs
|
||||
sudo journalctl -u caddy -f
|
||||
|
||||
# Validate configuration
|
||||
sudo caddy validate --config /etc/caddy/Caddyfile
|
||||
```
|
||||
|
||||
### If 502 Error Persists
|
||||
```bash
|
||||
# Check if target port is responding
|
||||
ss -tlnp | grep 3005
|
||||
|
||||
# Test direct connection
|
||||
curl localhost:3005
|
||||
|
||||
# Check Caddy is forwarding correctly
|
||||
curl -H "Host: docs.klas.chat" http://localhost:3005
|
||||
```
|
||||
|
||||
## ✅ Success Criteria
|
||||
|
||||
After applying the fixes, you should see:
|
||||
|
||||
1. **Caddy validation passes**: No syntax errors
|
||||
2. **Mintlify responds**: `curl localhost:3005` returns HTTP 200
|
||||
3. **docs.klas.chat loads**: No 502 error, shows documentation
|
||||
4. **Authentication works**: Basic auth prompt appears
|
||||
|
||||
## 🔄 Background Service (Optional)
|
||||
|
||||
To keep Mintlify running permanently:
|
||||
|
||||
```bash
|
||||
# Create systemd service
|
||||
sudo nano /etc/systemd/system/mem0-docs.service
|
||||
```
|
||||
|
||||
```ini
|
||||
[Unit]
|
||||
Description=Mem0 Documentation Server
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=klas
|
||||
WorkingDirectory=/home/klas/mem0/docs
|
||||
ExecStart=/usr/local/bin/mint dev --port 3005
|
||||
Restart=always
|
||||
RestartSec=5
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
```
|
||||
|
||||
```bash
|
||||
# Enable and start service
|
||||
sudo systemctl enable mem0-docs
|
||||
sudo systemctl start mem0-docs
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
**Summary**: Fix the Caddyfile indentation error, change the port to 3005, and start Mintlify on the correct port.
|
||||
Reference in New Issue
Block a user