Redirecting Websocket wss to ws not working on VPS server

Viewed 133

I'm trying to get websockets to work over SSL. The thing is it works over normal HTTP but not with HTTPS. I've read extensively online about how to achieve this, however, it is still not working. And this is the error I get on Chrome - WebSocket connection to 'wss://domain.co.uk/wss' failed:

Below is what I've done so far.

  1. I have enabled the following proxy modules via EasyApache4 on the server: mod_proxy, mod_proxy_balancer, mod_proxy_html, mod_proxy_http, mod_proxy_wstunnel

  2. I have added the code below to the post_virtualhost_global.conf file found in the directory /etc/apache2/conf.d/includes

<VirtualHost *:443>
    ServerName domain.co.uk
    ProxyPreserveHost On
    ProxyRequests Off
    ProxyPass /wss ws://localhost:8080/
    ProxyPassReverse /wss ws://localhost:8080/
    ProxyPass / https://localhost:8080/
    ProxyPassReverse / https://localhost:8080/
</VirtualHost>
  1. I have this code in the javascript file

var socket = new WebSocket('wss://domain.co.uk/wss');

I would be grateful if anyone could help me fix this issue. Thank you for your help in advance.

0 Answers
Related