From 9cd6ea4f02803e3b374cd31796cc02d3b940f657 Mon Sep 17 00:00:00 2001 From: renato97 Date: Wed, 4 Feb 2026 16:40:05 +0100 Subject: [PATCH] docs: Add server setup documentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 📚 Added comprehensive server setup documentation including: - Service information and endpoints - Systemd service management commands - Firewall configuration - Troubleshooting guide - Monitoring commands - Security recommendations 🤖 Generated with Claude Code (https://claude.com/claude-code) Co-Authored-By: Claude --- SERVER_SETUP.md | 212 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 212 insertions(+) create mode 100644 SERVER_SETUP.md diff --git a/SERVER_SETUP.md b/SERVER_SETUP.md new file mode 100644 index 0000000..b2ad5a9 --- /dev/null +++ b/SERVER_SETUP.md @@ -0,0 +1,212 @@ +# MangaReader - Configuración del Servidor VPS + +## 📋 Información del Servidor + +**URL:** http://gitea.cbcren.online:3001 +**Puerto:** 3001 +**Protocolo:** HTTP +**Estado:** ✅ Activo y corriendo + +## 🚀 Servicios Configurados + +### 1. Backend API (Node.js/Express) +- **Puerto:** 3001 +- **Servicio systemd:** `mangareader-backend.service` +- **Directorio:** `/home/ren/ios/MangaReader/backend` +- **Auto-reinicio:** ✅ Sí (systemd) +- **Acceso externo:** ✅ Sí (firewall ufw) + +### 2. Firewall (UFW) +- **Puerto 3001:** Abierto para TCP +- **Comando:** `sudo ufw allow 3001/tcp` +- **Estado:** ✅ Activo + +### 3. Storage +- **Directorio:** `/home/ren/ios/MangaReader/storage/` +- **Estructura:** + ``` + storage/ + └── manga/ + └── {mangaSlug}/ + └── chapter_{chapterNumber}/ + ├── page_001.jpg + ├── page_002.jpg + └── manifest.json + ``` + +## 🌐 Endpoints API + +### Manga Endpoints +- `GET /api/health` - Health check +- `GET /api/manga/:slug` - Info de manga +- `GET /api/manga/:slug/chapters` - Lista de capítulos +- `GET /api/chapter/:slug/images` - Imágenes de capítulo +- `GET /api/manga/:slug/full` - Info completa + +### Storage Endpoints +- `POST /api/download` - Descargar capítulo a VPS +- `GET /api/storage/chapters/:mangaSlug` - Listar capítulos descargados +- `GET /api/storage/chapter/:mangaSlug/:chapterNumber` - Verificar capítulo +- `GET /api/storage/image/:mangaSlug/:chapterNumber/:pageIndex` - Obtener imagen +- `DELETE /api/storage/chapter/:mangaSlug/:chapterNumber` - Eliminar capítulo +- `GET /api/storage/stats` - Estadísticas de almacenamiento + +## 🔧 Gestión del Servicio + +### Verificar estado +```bash +sudo systemctl status mangareader-backend.service +``` + +### Iniciar servicio +```bash +sudo systemctl start mangareader-backend.service +``` + +### Detener servicio +```bash +sudo systemctl stop mangareader-backend.service +``` + +### Reiniciar servicio +```bash +sudo systemctl restart mangareader-backend.service +``` + +### Ver logs +```bash +sudo journalctl -u mangareader-backend.service -f +``` + +### Ver logs recientes +```bash +sudo journalctl -u mangareader-backend.service -n 50 +``` + +## 📱 Configuración iOS App + +### APIConfig.swift +```swift +static let serverURL = "http://gitea.cbcren.online" +static let port: Int = 3001 +``` + +### URL Base Completa +``` +http://gitea.cbcren.online:3001 +``` + +## 🧪 Tests + +### Health Check +```bash +curl http://gitea.cbcren.online:3001/api/health +``` + +### Storage Stats +```bash +curl http://gitea.cbcren.online:3001/api/storage/stats +``` + +### Test Local +```bash +curl http://localhost:3001/api/health +``` + +## 🔒 Seguridad + +### Firewall +- Puerto 3001 abierto para acceso externo +- No se requiere autenticación (por ahora) + +### Recomendaciones Futuras +1. Implementar autenticación JWT +2. Usar HTTPS con certificado SSL +3. Rate limiting +4. Validación de input +5. Sanitización de rutas de archivos + +## 📊 Monitoreo + +### Revisar uso de disco +```bash +du -sh /home/ren/ios/MangaReader/storage/ +``` + +### Listar capítulos descargados +```bash +find /home/ren/ios/MangaReader/storage/ -name "manifest.json" +``` + +### Ver tamaño por manga +```bash +du -sh /home/ren/ios/MangaReader/storage/manga/*/ +``` + +## 🚨 Troubleshooting + +### El servicio no inicia +```bash +# Ver logs de error +sudo journalctl -u mangareader-backend.service -n 100 --no-pager + +# Verificar que node esté instalado +which node +node --version + +# Verificar puerto disponible +sudo ss -tlnp | grep 3001 +``` + +### No se puede acceder desde el exterior +```bash +# Verificar firewall +sudo ufw status + +# Verificar que el servicio esté corriendo +sudo systemctl status mangareader-backend.service + +# Verificar puerto desde adentro +curl http://localhost:3001/api/health +``` + +### Puerto ya en uso +```bash +# Ver qué está usando el puerto +sudo ss -tlnp | grep 3001 + +# Matar proceso si es necesario +sudo kill -9 +``` + +## 📝 Notas Importantes + +1. **Auto-inicio:** El servicio se inicia automáticamente al reiniciar el servidor +2. **Auto-reinicio:** Si el servicio falla, se reinicia automáticamente después de 10 segundos +3. **No interfiere con Gitea:** Usa puerto diferente (3001 vs 3000) +4. **No interfiere con otros servicios:** Puerto independiente y firewall específico +5. **Almacenamiento:** Usa /home/ren/ios/MangaReader/storage/ con espacio disponible (200GB) + +## 🎯 Próximos Pasos + +1. ✅ Backend configurado y corriendo +2. ✅ Firewall configurado +3. ✅ Servicio systemd activo +4. ⏭️ Clonar repo en Mac +5. ⏭️ Compilar app iOS +6. ⏭️ Instalar en iPad/iPhone via Sideloadly/3uTools +7. ⏭️ Probar descarga de capítulos +8. ⏭️ Verificar lectura offline + +## 📞 Soporte + +Si tienes problemas: +1. Verificar los logs: `sudo journalctl -u mangareader-backend.service -f` +2. Verificar el estado: `sudo systemctl status mangareader-backend.service` +3. Verificar firewall: `sudo ufw status` +4. Verificar conectividad: `curl http://localhost:3001/api/health` + +--- +**Última actualización:** 2026-02-04 +**Versión:** 1.0.0 +**Estado:** ✅ Producción