newz2000
newz2000

Reputation: 2640

Which reverse proxies work for node.js socket.io apps?

I have currently several apps running that are behind an Apache reverse proxy. I do this because I have one public IP address for multiple servers. I use VirtualHosts to proxy the right app to the right service. For example:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName nagios.myoffice.com

    ProxyPass /  http://nagios.myoffice.com/
    ProxyPassReverse / http://nagios.myoffice.com/
</VirtualHost>

This works fine for apps like PHP, Django and Rails, but I'd like to start experimenting with Node.js.

I've already noticed that apps that are behind the Apache proxy can't handle as high of a load as when I access them directly. Very likely because the Apache configuration is not ideal (not enough simultaneous connections maybe).

One of the coolest features I'd like to experiment with in node.js is the socket.io capabilities which I'm afraid will really expose the performance problem. Especially because, as I understand it, socket.io will keep one of my precious few Apache connections open constantly.

Can you suggest a reverse proxy server I can use in this situation that will let me use multiple virtualhosts and will not stifle the node.js apps performance too much or get in the way of socket.io experimentation?

Upvotes: 0

Views: 781

Answers (2)

matzahboy
matzahboy

Reputation: 3024

Although this introduces a new technology, I'd recommend using nginx as a front-end. nginx is a fast and hardened server written in c that is quite good at reverse proxying. Like node, it is event-driven and asynchronous.

You can use nginx to forward requests to various nodejs servers you are running, either load-balancing, or depending on the url (since it can do things like rewrites).

Upvotes: 0

Split Your Infinity
Split Your Infinity

Reputation: 4229

I recommend node-http-proxy. Very active community and proven in production.

FEATURES

  • Reverse proxies incoming http.ServerRequest streams
  • Can be used as a CommonJS module in node.js
  • Uses event buffering to support application latency in proxied requests
  • Reverse or Forward Proxy based on simple JSON-based configuration
  • Supports WebSockets
  • Supports HTTPS
  • Minimal request overhead and latency
  • Full suite of functional tests
  • Battled-hardened through production usage @ [nodejitsu.com][0]
  • Written entirely in Javascript
  • Easy to use API

Install using the following command

npm install http-proxy

Here is the Github page and the NPM page

Upvotes: 1

Related Questions