- I'm building a site that uses web sockets (technically Flash sockets) in order to provide real-time communication.
- I want to be able to support people behind corporate/academic firewalls that block everything except port 80
- I'd like to be able to run the site off of a single machine
Previously, I've been using Apache for HTTP serving combined with some python listening on a high-numbered socket for the websocket stuff, but that obviously won't work here.
I can always move the websocket stuff to a separate server, but I'd like to avoid paying for a second VPS (and have to talk to the database over the network instead of locally). Is there a good way to do this (nodejs, nginx, ..?), or is it not worth the headache?
GlassFish (and grizzly) support both HTTP and websockets traffic on the same port if a java server is an option.
Of course you can do this.
Firstly you have to check your Apache version. You should have 2.4+ version. I will show you command for my server on Ubuntu 14.4.
Secondly, turn on necessary apache modules:
Open conf of your domain, in my case that was a path to file:
Next, append this code
Finaly restart your apache
Have fun!
The short answer is no, because you can only have one process listening on one port. You could try using port 443, since that is not going to be blocked either, as long as you also do not use https.
For secure websocket, all I needed to do was to add these three lines to my https virthualhost :
And enable the mod_proxy_wstunnel apache module (I'm running apache 2.4.10) :
Another possibility is to use mod_proxy in apache to redirect the requests to a websocket server.
YES, by using node.js. Express or connect for the HTTP file serving and socket.io for the WebSocket stuff.
Example: