Is redirecting all websocket (wss) traffic possible?

I have looked and looked, through this and other forums, and haven’t found a solution that is workable for my situations.

I have a an app running on an old server. It listens on port 443 for people looking to load the webpage to access the tool, and also for websocket connection requests from endpoints reaching back out to the server.

On my new server, 443 has been changed to 4300. I would like to redirect ALL traffic that matches those requests to the new server. The problem I run into is that I have other things running on port 443 on both the old and new server, so there’s not a clear path to say just forward the universe. For instance:

sub1.server.com is the same on both old and new
sub2.server.com is 443 on the old, and 4300 on the new, and includes https and wss connections.

I’m half drunk from lack of sleep and really annoyed that I haven’t found the solution, which I’m sure is a 5 minute fix that I just haven’t located or figured out yet. Can someone point me in the right direction, please?

Thanks!

If @blas is on tomorrow, maybe he knows. You might also try asking on the Workers Discord app, as I suspect that’s what it will take to get this work if it’s even possible.

Hi there @mike29,

I’m asking the team and will let you know if find anything that may help you with this project.

Cheers,

1 Like

Ok, so what you’ll want to do to make this work with a Cloudflare Worker is to look for the header Upgrade: websocket on the request, and rewrite/redirect those that have the header.

Just as @sdayman pointed out above, feel free to join the Workers Discord if you’d like more specific guidance regarding this.

I hope this helps!

1 Like

You guys are freaking great!! Started doing a little reading. Not much in the way of useful examples for this sort of thing yet, although I suspect there will be in the coming months. I’ll see if I might be able to contribute something useful.

Thank you so much for the quick reply and pointing the way. I will likely be studying this for a bit. Workers are fantastic, and a huge topic to learn. Seems like you can almost replace your DNS settings with workers. Not sure that would be worth the trade-offs, but still, very powerful to have those abilities.

Thanks again!

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.