Hello everyone,
I’m having trouble configuring a WebGL app to connect to a remote Unity server on an HTTPS website. I’m using Netcode for GameObjects for the networking logic. The server is a standard Debian setup.
The setup works fine over plain HTTP (port 80). The WebGL app loads via an nginx reverse proxy to port 8080 (where I’m running a Node.js server for WebGL). The client then connects to the Unity server at <my server IP>:7777
without any issues.
However, once I switch to HTTPS, things start to break down. The WebGL app still loads without any problem, but when it attempts to connect to the Unity server, I receive the following error:
SecurityError: Failed to construct ‘WebSocket’: An insecure WebSocket connection may not be initiated from a page loaded over HTTPS.
I’ve tried several things:
- Setting up reverse proxies in nginx to handle WebSocket traffic.
- Enabling and disabling Unity Transport encryption.
- Using domain names instead of IP addresses.
- Hardcoding my SSL certificate and keys using
SetClientSecrets
andSetServerSecrets
in Unity Transport.
Nothing seems to work so far.
Does anyone have documentation, examples, or a step-by-step tutorial on how to correctly set this up? I’m not sure what the best approach is at this point.
Thanks in advance for any help!