From 915ed53b422c5be28a4eb4319940871f96de98ff Mon Sep 17 00:00:00 2001 From: Carsten Graf Date: Wed, 3 Sep 2025 17:33:36 +0200 Subject: [PATCH] Push WesocketChanges --- apache-ssl-config.conf | 19 ++++++++++++---- websocket-setup-commands.sh | 45 +++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 4 deletions(-) create mode 100755 websocket-setup-commands.sh diff --git a/apache-ssl-config.conf b/apache-ssl-config.conf index 79d21c7..ccaa5dc 100644 --- a/apache-ssl-config.conf +++ b/apache-ssl-config.conf @@ -19,14 +19,25 @@ # Wichtig für Kamera-Zugriff Header always set Permissions-Policy "camera=self, microphone=()" - # Reverse Proxy zu Node.js + # WebSocket Support - MUSS vor dem generellen Proxy stehen + RewriteEngine On + RewriteCond %{HTTP:Upgrade} websocket [NC] + RewriteCond %{HTTP:Connection} upgrade [NC] + RewriteRule ^/?(.*) "ws://localhost:3000/$1" [P,L] + + # Socket.IO spezifische WebSocket-Routen + ProxyPass /socket.io/ ws://localhost:3000/socket.io/ + ProxyPassReverse /socket.io/ ws://localhost:3000/socket.io/ + + # Standard HTTP/HTTPS Reverse Proxy zu Node.js ProxyPreserveHost On + ProxyPass /socket.io/ ! ProxyPass / http://localhost:3000/ ProxyPassReverse / http://localhost:3000/ - # WebSocket Support für Live-Updates - ProxyPass /socket.io/ ws://localhost:3000/socket.io/ - ProxyPassReverse /socket.io/ ws://localhost:3000/socket.io/ + # WebSocket Proxy-Einstellungen + ProxyTimeout 3600 + ProxyBadHeader Ignore # Logging ErrorLog ${APACHE_LOG_DIR}/ninjaserver_ssl_error.log diff --git a/websocket-setup-commands.sh b/websocket-setup-commands.sh new file mode 100755 index 0000000..9f3ffba --- /dev/null +++ b/websocket-setup-commands.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +echo "🔧 Apache WebSocket Support Setup" +echo "=================================" + +# Kopiere die aktualisierte Apache-Konfiguration +echo "Kopiere Apache-Konfiguration..." +sudo cp /root/ninjaserver/apache-ssl-config.conf /etc/apache2/sites-available/ninjaserver-ssl.conf +echo "✅ Konfiguration kopiert" + +# Apache Module aktivieren +echo "Aktiviere benötigte Apache-Module..." +sudo a2enmod proxy +sudo a2enmod proxy_http +sudo a2enmod proxy_wstunnel +sudo a2enmod rewrite +sudo a2enmod headers +sudo a2enmod ssl + +echo "✅ Module aktiviert" + +# SSL Site aktivieren (falls noch nicht geschehen) +echo "Aktiviere SSL-Site..." +sudo a2ensite ninjaserver-ssl + +# Standard-Site deaktivieren (optional) +echo "Deaktiviere Standard-Site..." +sudo a2dissite 000-default + +# Apache-Konfiguration testen +echo "Teste Apache-Konfiguration..." +sudo apache2ctl configtest + +if [ $? -eq 0 ]; then + echo "✅ Apache-Konfiguration ist gültig" + echo "Starte Apache neu..." + sudo systemctl restart apache2 + echo "✅ Apache wurde neugestartet" + + echo "" + echo "🎉 WebSocket Support sollte jetzt funktionieren!" + echo "Teste die Verbindung mit: wss://ninja.reptilfpv.de/socket.io/" +else + echo "❌ Apache-Konfiguration hat Fehler - bitte überprüfen" +fi