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 :
<VirtualHos开发者_开发百科t *: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?
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.
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.
You cannot. Its a fundamental design principle of the sockets library that the port number identifies a single endpoint for a network interface. If Apache or any other program has port 80 then it belongs to that program and only that program.
Think about it if you were somehow to "share" port 80 with Apache how could I which choose which process to send my message to?
It is possible to have one process listening on one network interface (say Apache using port 80 your Ethernet LAN ) and another process using the same port number on another interface (say Proxy server using port 80 on your Wireless Lan).
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?
精彩评论