Alright, bare with me, cause I'm slowly losing my mind over this and I'd rather explain it in depth than half ass it.
Setup
So far I've been developing local and everything was working fairly well. I started to move my development to my home server with coder, so that I could develop in a more consistent environment. This also means that I want to access the applications I develop via a domain I own. So I'm running nginx as webserver and reverse proxy and got cloudflare routing the domain to my server.
I have the option "always use https" enabled, which means requests over http are automatically redirected to https via cloudflare. Additionally cloudflare is configured in flexible encryption mode, meaning the traffic is only encrypted via browser and cloudflare, not between cloudflare and my server.
That means I can serve my web applications via http and cloudflare covers ssl and certificates.
Problem
For the purpose of this post, let's assume my domain is "cool.dev" with the following routes:
- "/" a website that will communicate with the colyseus server
- "/colyseus" - my colyseus server
If I use var client = new Colyseus.Client("ws://cool.dev/colyseus");
I get the error
Blocked loading mixed active content “http://cool.dev/colyseus/matchmake/create/game”
If I use var client = new Colyseus.Client("wss://cool.dev/colyseus");
I get the error
Error: invalid method "matchmake"
More information
Opening https://cool.dev/colyseus/matchmake in my browser successfully returns a list of available rooms.
Calling either ws://cool.dev/colyseus/matchmake/create/game or wss://cool.dev/colyseus/matchmake/create/game with weasel successfully connects with the server (although I get the server side error "Error: seat reservation expired." and then the connection is closed immediately).
My nginx config:
server {
set $forward_scheme http;
set $server "192.168.178.47";
set $port 1234;
listen 8080;
listen [::]:8080;
server_name cool.dev;
# Block Exploits
include conf.d/include/block-exploits.conf;
access_log /data/logs/proxy_host-7.log proxy;
location /colyseus {
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Scheme $scheme;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_pass http://192.168.178.47:2567;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_http_version 1.1;
proxy_cache_bypass $http_upgrade;
proxy_read_timeout 86400s;
proxy_send_timeout 86400s;
}
location / {
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_http_version 1.1;
# Proxy!
include conf.d/include/proxy.conf;
}
# Custom
include /data/nginx/custom/server_proxy[.]conf;
}
access log with wss:
[09/May/2020:17:12:15 +0200] - 200 200 - POST http cool.dev "/colyseus/matchmake/create/game" [Client <super-secret-ip6-address>] [Length 63] [Gzip -] [Sent-to 192.168.178.47] "Mozilla/5.0 (X11; Linux x86_64; rv:76.0) Gecko/20100101 Firefox/76.0" "https://cool.dev/"
I would really appreciate any input on the matter.