SSL Proxy via NGINX does not establish a connection (Unity, Linux)
I am hosting a game server (Websocket-sharp + Unity Headless) on a linux server with NGINX as a proxy.
NGINX configuration
server {
server_name game.okdev.se; # managed by Certbot
location / {
proxy_http_version 1.1;
proxy_pass http://localhost:5009;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header HOST $host;
proxy_set_header X_Forwarded_For $remote_addr;
proxy_redirect default;
client_max_body_size 1000m;
}
listen [::]:443 ssl; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/game.okdev.se/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/game.okdev.se/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
Server C# code
I'm not using SSL with C# but rather the SSL part should be handled by NGINX, this exact setup has worked for previous
projects using NodeJS and Websockets. The only path for my Websocket server is /
wssv = new WebSocketServer(port);
wssv.AddWebSocketService("/", () => new SocketInstance(this));
Unity Client C# code Connecting via NGINX and SSL does not work at all.
ws = new WebSocket("wss://game.okdev.se/");
Connecting with the Unity client to the direct (port forwarded) port, without SSL and bypassing NGINX works.
ws = new WebSocket("ws://game.okdev.se:5009/");
@yogehster I have the same issue and trying much things since many days. Any news on your end ? did you solve it somehow ? : (
Have the same issue here, and when "bypass" with ws and local port behind NGINX it works.
I first tried MS "System.Net.WebSockets.ClientWebSocket" and that library do connect via NGINX but I find it messy to work with, I prefere asing WebSocketSharp.
Any solution on this issue?
I'm using 1.0.3-rc11
I fixed the same issue.
wssv = new WebSocketServer(port);
wssv.AllowForwardedRequest = true;