From 5352dd4ac9d90940f2a7c4d1ad7105b48395c971 Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Wed, 3 Sep 2025 20:01:52 +0200 Subject: [PATCH] =?UTF-8?q?Fix:=20WebSocket-Verbindungen=20=C3=BCber=20Apa?= =?UTF-8?q?che-Proxy=20routen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Apache-Konfiguration: - Füge WebSocket-Proxy für /ws/ Pfad hinzu - Leite WebSocket-Upgrade-Header korrekt weiter Frontend-Konfiguration: - Socket.io verwendet jetzt VITE_API_BASE_URL (über /socket.io/ Proxy) - Daemon WebSocket verwendet wss://www.your-part.de/ws - Chat WebSocket verwendet wss://www.your-part.de/ws Dies löst die 'operation is insecure' Fehler und ermöglicht WebSocket-Verbindungen über HTTPS. --- frontend/.env.server | 4 ++-- frontend/src/store/index.js | 6 +++--- yourpart-https.conf | 10 ++++++++++ 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/frontend/.env.server b/frontend/.env.server index e5a0c70..b6b5b8e 100644 --- a/frontend/.env.server +++ b/frontend/.env.server @@ -1,5 +1,5 @@ VITE_API_BASE_URL=https://www.your-part.de VITE_TINYMCE_API_KEY=xjqnfymt2wd5q95onkkwgblzexams6l6naqjs01x72ftzryg -VITE_DAEMON_SOCKET=wss://www.your-part.de:2020 -VITE_CHAT_WS_URL=wss://www.your-part.de:1235 +VITE_DAEMON_SOCKET=wss://www.your-part.de/ws +VITE_CHAT_WS_URL=wss://www.your-part.de/ws diff --git a/frontend/src/store/index.js b/frontend/src/store/index.js index 643da6e..fdfc191 100644 --- a/frontend/src/store/index.js +++ b/frontend/src/store/index.js @@ -85,8 +85,8 @@ const store = createStore({ if (currentSocket) { currentSocket.disconnect(); } - console.log('🔌 Initializing Socket.io connection to:', import.meta.env.VITE_DAEMON_SOCKET); - const socket = io(import.meta.env.VITE_DAEMON_SOCKET, { + console.log('🔌 Initializing Socket.io connection to:', import.meta.env.VITE_API_BASE_URL); + const socket = io(import.meta.env.VITE_API_BASE_URL, { secure: true, transports: ['websocket', 'polling'] }); @@ -103,7 +103,7 @@ const store = createStore({ socket.on('connect_error', (error) => { console.error('❌ Socket.io connection error:', error); - console.error('❌ URL attempted:', import.meta.env.VITE_DAEMON_SOCKET); + console.error('❌ URL attempted:', import.meta.env.VITE_API_BASE_URL); }); commit('setSocket', socket); diff --git a/yourpart-https.conf b/yourpart-https.conf index afb62d3..17a56cc 100644 --- a/yourpart-https.conf +++ b/yourpart-https.conf @@ -25,6 +25,16 @@ # WebSocket-Requests an Backend weiterleiten ProxyPass "/socket.io/" "http://localhost:2020/socket.io/" ProxyPassReverse "/socket.io/" "http://localhost:2020/socket.io/" + + # WebSocket-Proxy für Daemon-Verbindungen + ProxyPass "/ws/" "ws://localhost:2020/" + ProxyPassReverse "/ws/" "ws://localhost:2020/" + + # WebSocket-Upgrade-Header + RewriteEngine on + RewriteCond %{HTTP:Upgrade} websocket [NC] + RewriteCond %{HTTP:Connection} upgrade [NC] + RewriteRule ^/ws/(.*)$ "ws://localhost:2020/$1" [P,L] ErrorLog /var/log/apache2/yourpart.error.log CustomLog /var/log/apache2/yourpart.access.log combined