Update Apache and backend configuration for direct Socket.IO HTTPS support

This commit modifies the Apache configuration to reflect that Socket.IO now runs directly on HTTPS port 3051, eliminating the need for Apache proxying. Additionally, the backend server setup is updated to create an HTTPS server for Socket.IO, including error handling for SSL certificate loading. The frontend service is also adjusted to connect to the new HTTPS endpoint, ensuring compatibility with the updated architecture.
This commit is contained in:
Torsten Schulz (local)
2025-11-16 09:31:16 +01:00
parent baf5bda6f2
commit 5ddf998672
4 changed files with 127 additions and 51 deletions

View File

@@ -30,45 +30,8 @@
ProxyRequests Off
# WebSocket-Proxy für Socket.IO
# WICHTIG: Diese LocationMatch muss VOR den anderen ProxyPass-Direktiven stehen
# WICHTIG: mod_proxy_wstunnel muss aktiviert sein (sudo a2enmod proxy_wstunnel)
# WICHTIG: mod_rewrite muss aktiviert sein (sudo a2enmod rewrite)
#
# HINWEIS: Seit Apache 2.4.47 kann mod_proxy_http WebSockets direkt verarbeiten.
# Falls die RewriteRule nicht funktioniert, verwende die alternative Konfiguration unten.
# WebSocket-Upgrade erkennen und weiterleiten (wss:// -> ws://)
# Verwende RewriteRule, um WebSocket-Upgrades zu erkennen und weiterzuleiten
<LocationMatch "^/socket\.io/">
RewriteEngine on
RewriteCond %{HTTP:Upgrade} websocket [NC]
RewriteCond %{HTTP:Connection} upgrade [NC]
RewriteRule ^/socket\.io/?(.*) ws://localhost:3050/socket.io/$1 [P,L,QSA]
# Fallback für HTTP-Polling (wird verwendet, wenn RewriteRule nicht greift)
ProxyPass http://localhost:3050/socket.io/
ProxyPassReverse http://localhost:3050/socket.io/
ProxyPreserveHost On
ProxyAddHeaders On
<IfModule mod_headers.c>
RequestHeader set X-Forwarded-Proto "https"
RequestHeader set X-Real-IP %{REMOTE_ADDR}s
RequestHeader set X-Forwarded-For %{REMOTE_ADDR}s
</IfModule>
</LocationMatch>
# ALTERNATIVE: Direkte ProxyPass-Konfiguration (funktioniert ab Apache 2.4.47)
# Falls die RewriteRule nicht funktioniert, kommentiere die obige LocationMatch aus
# und verwende stattdessen diese Konfiguration:
# ProxyPass /socket.io/ ws://localhost:3050/socket.io/
# ProxyPassReverse /socket.io/ ws://localhost:3050/socket.io/
# ProxyPass /socket.io/ http://localhost:3050/socket.io/
# ProxyPassReverse /socket.io/ http://localhost:3050/socket.io/
# Timeout für alle Proxy-Verbindungen (außerhalb von LocationMatch)
ProxyTimeout 3600
# HINWEIS: Socket.IO läuft jetzt direkt auf HTTPS-Port 3051 (nicht über Apache-Proxy)
# Siehe backend/SOCKET_IO_SSL_SETUP.md für Details
# API-Routen
ProxyPass /api http://localhost:3050/api