Reputation: 196
I have an Apache-Server running my PHP-Application on Port 80. The PHP-Application communicates with the NodeJS-Server (socket.io) over Port 3000.
Due to firewall restrictions, I should only use Port 80. Therefore I need to specify an url like /nodejs/ that is reversed internally on the server to port 3000 (NodeJS).
Is it better (in respect of performance) to use Apache (mod_proxy) as Reverse-Proxy to forward NodeJS-Data to NodeJS or is it better to do that on NodeJS (e.g. with https://github.com/nodejitsu/node-http-proxy) and therefore let NodeJS running on Port 80 and forward all non-NodeJS-Data internally to Apache (which then would run on another port)?
I probably have a bit more socket.io calls than normal HTTP-Requests.
Upvotes: 1
Views: 1905
Reputation: 63663
If you just need proxying, you should use something like HAProxy, which is designed specifically for that.
Apache is not that good at proxying, because it has to fork or start a new thread for each connection (thus loosing all the benefit of Node).
Further than that, I wouldn't use Apache at all if I needed to optimize things, NGINX is much better as a server (it's even faster than Node.js for serving static files for example).
If you're looking for Node.js proxy solutions HTTP-Proxy and Bouncy are the best:
Resources:
Upvotes: 2