Does it make sense to reverse proxy Node.js through Apache

apache-2.2node.jsPROXYreverse-proxy

Perfomancewise, does it make sense to redirect requests from an Apache VirtualHost to a Node.js instance? Does proxying counterbalance the awesome Node.js performance?


FYI: I also need a couple of PHP web apps to be parsed and run on the same machine, that's the only reason why I'm even considering using a reverse proxy.

According to my research, Nginx has less overhead and thus performs slightly better but unfortunately doesn't support HTTP/1.1.

I also thought about having Node.js serve as the reverse proxy and sending certain requests to Apache (which then processes PHP files, for example), but I heard that there could be lots of security issues.

Best Answer

I would suggest that setting up Apache to reverse proxy to Node.js is against the intent of Node.js. Node is very lightweight - its overhead is minimal. Launching an apache process to handle the Node.js stream negates the point of using Node.js (essentially, you would be limited by the performance of Apache).

Node is sometimes not considered stable enough to run without monitoring and might not be the ideal front end. I might suggest placing either Squid or HAproxy in front of Node and Apache, allow either of those to serve as your proxy, and run Node and Apache on different ports (e.g. 8080, 8081). Both Squid and HAProxy have good performance and should meet your needs without detracting from either backend server.

Related Topic