Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Websocket port problem because already in use?

Based on the expert recommendation of the IANA, the WebSocket protocol by default uses port 80 for regular WebSocket connections.

How can I make my websocket listen to port 80 when the Apache server is already listening to this port?

I made it works when my WebSocket were using port 12345 but I do not want to open to everyone that port and IANA recommend port 80... but I do not get how to make it works with that port?

Idea #1

I have read that for Jabber server that you can use Apache to redirect the call. Here is an example from this website :

<VirtualHost *:80>
    Servername yourdomain.com
    DocumentRoot /var/www
    AddDefaultCharset UTF-8
    RewriteEngine On
    RewriteRule ^/http-bind/ http://jabber.yourdomain.com:5280/http-bind/ [P]
</VirtualHost>

Maybe I can do something like that with the websocket... what is your thought?

like image 646
Patrick Desjardins Avatar asked Nov 04 '22 18:11

Patrick Desjardins


2 Answers

You don't. The rule, in every OS I know of, is one process, one port. And that makes sense. If you have two processes listening to the same port, then who is to say which one should handle it? You'll have to expose some other port on that machine.

like image 81
cwallenpoole Avatar answered Nov 14 '22 23:11

cwallenpoole


The websocket protocol uses port 80 (HTTP) or 443 (HTTPS). What we've done is use port 80 for our webserver and port 443 for the websocket. This prevents the clash but still follows the standard.

like image 31
parsley72 Avatar answered Nov 15 '22 01:11

parsley72