I have Caddy as my file server, with my Caddyfile:
foobar.nl {
redir https://www.{host}{uri}
}
www.foobar.nl {
file_server browse
reverse_proxy /wss59fps localhost:9090
handle_path /59fps/* {
rewrite * /59fps/client{uri}
file_server
}
}
I run nodejs to handle the websockets at /wss59fps
on port 9090.
const express = require('express');
const WebSocket = require('ws');
const app = express();
const server = require('http').createServer(app);
const wss = new WebSocket.Server({ server, path: '/wss59fps' });
const PORT = process.env.PORT || 9090;
In my index.html if I use (ws):
const socket = new WebSocket('ws://foobar.nl:9090/wss59fps');
Then I get:
DOMException: The operation is insecure.
In my index.html if I use (wss):
const socket = new WebSocket('wss://foobar.nl:9090/wss59fps');
Then I get:
Firefox can’t establish a connection to the server at wss://foobar.nl:9090/wss59fps.
My nodejs server is running on 9090 and the port is allowed for ufw.
At this point I’m lost of how to tackle this problem. Where is the problem likely at? And how can I trace steps to isolate the problem?