i'm stuck really stuck, i'm on apache 2.4 on a godaddy VPS server running almaliux8 and i'm trying to build a customer loyalty app for my company using Websockets to communicate between the cashier and the customer. Without even trying to build the app, i'm testing the infrastructure of building a WSS websocket for my HTTPS website. I've followed all the tutorials and forums as best as i can but i'm still relatively cluless. Please see the php and configs below. I'm able to connect to the websocket on ws://site.com:8091 wihtout any issues, but switching to wss://site.com/ gives me a 404 error. i've tried everything from the /wss2/ to checking firewall settings and even chatgpt but have not been able to get any progress. Appreciate some comments.
I've added the following in one of the included files for my httpd.conf
LoadModule ssl_module modules/mod_ssl.soLoadModule proxy_module modules/mod_proxy.soLoadModule proxy_http_module modules/mod_proxy_http.so#LoadModule proxy_html_module modules/mod_proxy_html.soLoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so<VirtualHost *:443> SSLEngine on RewriteCond %{HTTP:Upgrade} =websocket [NC] RewriteRule /(.*) ws://localhost:8091/$1 [P,L] RewriteRule /(.*) http://localhost:8091/$1 [P,L] ServerName www.lamskitchen.co SSLProxyEngine On ProxyPreserveHost On ProxyRequests Off ProxyPass / ws://localhost:8091/ ProxyPassReverse / ws://localhost:8091/ SSLCertificateFile /etc/ssl/certs/website.co.crt SSLCertificateKeyFile /etc/ssl/private/website.co.key SSLCertificateChainFile /etc/ssl/certs/website.co.bundle.crt</VirtualHost>
The following is the Chat.php class file config
<?phpnamespace MyApp;use Ratchet\MessageComponentInterface;use Ratchet\ConnectionInterface;class Chat implements MessageComponentInterface{ protected $clients; protected $clientCount; public function __construct() { $this->clients = new \SplObjectStorage; $this->clientCount = 0; } public function onOpen(ConnectionInterface $conn) { $this->clients->attach($conn); $this->clientCount++; echo "New connection! ({$conn->resourceId})\n"; } public function onMessage(ConnectionInterface $from, $msg) { echo "Received message from {$from->resourceId}: {$msg}\n"; // Pass the received message to all other clients foreach ($this->clients as $client) { if ($from !== $client) { $client->send($msg); } } } public function onClose(ConnectionInterface $conn) { $this->clients->detach($conn); $this->clientCount--; echo "Connection {$conn->resourceId} has disconnected\n"; } public function onError(ConnectionInterface $conn, \Exception $e) { echo "An error has occurred for connection {$conn->resourceId}: {$e->getMessage()}\n"; $conn->close(); }}
And finally the socket.php file
<?phpuse Ratchet\Http\HttpServer;use Ratchet\Server\IoServer;use Ratchet\WebSocket\WsServer;use MyApp\Chat;require dirname(__DIR__) . '/vendor/autoload.php';$sslContext = ['ssl' => ['local_cert' => '/etc/ssl/certs/lamskitchen.co.crt','local_pk' => '/etc/ssl/private/lamskitchen.co.key','verify_peer' => false, ],];$chat = new Chat(); // Replace with your Chat application class$wsServer = new WsServer($chat);$server = IoServer::factory( new HttpServer($wsServer), 8091,'0.0.0.0', $sslContext);$wsServer->enableKeepAlive($server->loop, 10);$server->run();