Websocket (Ratchet/zeroMQ) with Apache proxy and SSL - on a Plesk server

Viewed 610

I'm trying to get a websocket/push-server to run with SSL and can't get it to work. Here are some informations about what I'm using and what I've done so far:

  • Ubuntu 16.04.6 LTS‬ server with Plesk 17.8.11
  • Apache version 2.4.18
  • Ratchet and zmq extension installed
  • autobahn.js for websocket connection
  • PHP-FPM (7.2.19) served by Apache
  • Firewall disabled for testing
  • Apache mods enabled: proxy, proxy_balacer, proxy_fcgi, proxy_http, proxy_wstunnel

When I use an non-SSL connection via autobahn.js to ws://my.domain.net:8888/ everything works perfectly fine. As soon as I try to use wss://my.domain.net/wss/ I get 504 connection timeouts in my browser.

Part of my push-server.php:

$context = new React\ZMQ\Context($loop);
$pull = $context->getSocket(ZMQ::SOCKET_PULL);
$pull->bind('tcp://0.0.0.0:5555'); // set to 0.0.0.0 for testing, was 127.0.0.1 before but didn't work either
$pull->on('message', array($pusher, 'onMessage'));

$webSock = new React\Socket\Server('0.0.0.0:8888', $loop);
$webServer = new Ratchet\Server\IoServer(
    new Ratchet\Http\HttpServer(
        new Ratchet\WebSocket\WsServer(
            new Ratchet\Wamp\WampServer(
                $pusher
            )
        )
    ),
    $webSock
);

$loop->run();

The server is listening on both ports:

php        3957               root   17u     IPv4          823972456      0t0       TCP *:8888 (LISTEN)
ZMQbg/0    3957  3958         root   17u     IPv4          823972456      0t0       TCP *:8888 (LISTEN)
ZMQbg/1    3957  3959         root   17u     IPv4          823972456      0t0       TCP *:8888 (LISTEN)


php        3957                  root   16u     IPv4          823972455      0t0       TCP *:5555 (LISTEN)
ZMQbg/0    3957  3958            root   16u     IPv4          823972455      0t0       TCP *:5555 (LISTEN)
ZMQbg/1    3957  3959            root   16u     IPv4          823972455      0t0       TCP *:5555 (LISTEN)

My apache config:

SSLProxyEngine on
ProxyRequests Off
SetEnv proxy-initial-not-pooled 1
ProxyPass /wss/ https://my.domain.net:8888/
ProxyPassReverse /wss/ https://my.domain.net:8888/

I also tried to use

ProxyPass /wss/ wss://my.domain.net:8888/

but then I get the following error message

[proxy:warn] AH01144: No protocol handler was valid for the URL /wss/. If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule.

Now when I try to open a connection with autobahn.js to wss://my.domain.net/wss/ the request loads for a while and ends in a 504 Gateway Time-out and I get the following error message:

[proxy_http:error] (103)Software caused connection abort: [client x.x.x.x:33362] AH01102: error reading status line from remote server my.domain.net:8888
[proxy:error] [client x.x.x.x:33362] AH00898: Error reading from remote server returned by /wss/

Part of the Request Headers:

Cache-Control: no-cache
Connection: Upgrade
Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits
Sec-WebSocket-Key: WG/ajAsTaVhBgEeEz5wiUg==
Sec-WebSocket-Protocol: wamp
Sec-WebSocket-Version: 13
Upgrade: websocket

Part of the Response Headers:

Connection: keep-alive
Content-Length: 578
Content-Type: text/html
Server: nginx

Opening the https://my.domain.net/wss/ in a browser ends in an Gateway Time-out as well, served by nginx.

I've spent like 2 days already googling and trying different solutions but nothing seems to work. If you need more information, please let me know. Thanks in advance!

0 Answers
Related