So I currently have apache with a proxy pass which redirects all requests to an express api running using the http node module, I also have a letsencrypt ssl certificate installed and all is working fine on this part. However, When I try to open a secure websocket connection it errors. I have only the bare minimum experience as far as apache configuration and ssl configuration goes so please bare with me.
On my server:
server.ts
import * as http from 'http';
import * as Websocket from 'ws';
import * as express from 'express';
...
const app = express();
const server = http.createServer(app);
const wss = new Websocket.Server({ server, path: '/ws' });
...
server.listen(3005, () => {
console.log('Server started on port 3005');
});
On the browser:
index.js
const ws = new WebSocket('wss://mydomain.tld/ws');
And my apache config file for the domain
mydomain.tld.conf
<VirtualHost *:443>
ServerName mydomain.tld
ProxyPreserveHost On
<Proxy *>
Order allow,deny
Allow from all
</Proxy>
ProxyPass / http://127.0.0.1:3005/ retry=0
ProxyPassReverse / http://127.0.0.1:3005/
RewriteEngine on
RewriteCond %{SERVER_NAME} =mydomain.tld
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
So again to quickly sum up the issue, I can create successful ssl secured https requests but not websocket requests to the server. Thanks in advance.