Reverse Proxy and Unity Game Server Setup in Docker hosted on playfab: Configuration Issue when using same container for nguinx and game server

I am trying to set up a Unity game server alongside an Nginx reverse proxy within the same Docker container. Internally, everything seems to work fine—Nginx is forwarding requests to the Unity game server, and both components are active. However, when I try to connect externally (e.g., using Postman or a WebGL client), the connection fails or hangs indefinitely.

Here’s my setup:

  • Unity Game Server: Configured with SimpleWebTransport on port 7777.
  • Nginx: Configured to listen on port 80 and forward WebSocket connections to the game server.
  • PlayFab Local Multiplayer Agent: Used for testing the game server locally with port mappings in the configuration.

Attempts:

  1. Verified ports are open (ss -tuln shows listening).
  2. Checked Nginx logs—connections are logged but fail to reach the Unity server externally.
  3. Updated file permissions and ensured logs are writable.
  4. Tested WebSocket connections directly to the Unity server (works internally but not externally).
  5. Followed Unity’s SimpleWebTransport documentation and updated code to ensure compatibility.

Still, external connections via Nginx are not functioning as expected. Has anyone successfully deployed a similar setup or encountered this issue? Any insights or solutions would be greatly appreciated!

Why do you need the nginx reverse proxy? if you expose the port 7777 of the docker, things can connect to it.

I need the Nginx reverse proxy because I am trying to add support for WebGL build. WebGL builds require secure WebSocket connections (wss://) when running on HTTPS domains. Without the reverse proxy, I get the following error in the browser:

SecurityError: Failed to construct ‘WebSocket’: An insecure WebSocket connection may not be initiated from a page loaded over HTTPS.

By using Nginx, I can terminate the SSL connection at the reverse proxy and forward the WebSocket requests securely to the Unity server running on port 7777. This approach ensures compatibility with WebGL clients while maintaining a secure connection.

So dont use insecure websockets?

Error: Failed to construct Websocket; insecure Websocket connection. - Unity Engine - Unity Discussions

I dont remember having this issue when i stuck my server in a docker container, and had my website using relay, but that could be cos I was using relay