Dynamic WebSocket Proxy Using Cloudflare Tunnel

What is the name of the domain?

Related to

Cloudflare Tunnel

What is the issue you’re encountering

Hi everyone, I have a Node.js server running in a Docker container, accessible via a Cloudflare Tunnel at api.mydomain.com Clients can request the API for creation of additional services, each of which has a WebSocket server running on a specific port between 11,000 and 25,000. I need to enable my clients to connect to these WebSocket services dynamically through a single entry point. Currently, each WebSocket service operates on a different port, and I need a solution to allow clients to connect to the appropriate WebSocket service using a single domain without creating subdomains for each port. I’ve heard of using tokens to identify connections, but I’m not sure how to implement this with Cloudflare Tunnel. Any suggestions or examples would be greatly appreciated! Thanks in advance for your help!

You could set the port as a header and then use a local reverse proxy to route traffic based on that header.

Something like this: Using nginx map directive to dynamically set proxy upstream - Stack Overflow

Though I would prefer to use a different name for every service. That just makes a lot of stuff easier in the long term.