<IfModule mod_ssl.c>
<VirtualHost *:4443>
    ServerName www.your-part.de

    SSLEngine on
    Protocols http/1.1

    Include /etc/letsencrypt/options-ssl-apache.conf
    SSLCertificateFile /etc/letsencrypt/live/www.your-part.de/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/www.your-part.de/privkey.pem

    ProxyPreserveHost On
    RequestHeader set X-Forwarded-Proto "https"
    AllowEncodedSlashes NoDecode

    # WebSocket-Upgrade für Socket.io (muss VOR ProxyPass stehen)
    RewriteEngine on
    RewriteCond %{HTTP:Upgrade} websocket [NC]
    RewriteCond %{HTTP:Connection} upgrade [NC]
    RewriteRule ^/socket.io/(.*)$ "ws://127.0.0.1:2020/socket.io/$1" [P,L]

    # HTTP-Proxy für Socket.io (Fallback für Polling)
    ProxyPass        "/socket.io/"  "http://127.0.0.1:2020/socket.io/" retry=0
    ProxyPassReverse "/socket.io/"  "http://127.0.0.1:2020/socket.io/"

    ErrorLog  /var/log/apache2/yourpart-ws.error.log
    CustomLog /var/log/apache2/yourpart-ws.access.log combined
</VirtualHost>
</IfModule>
