I'm surprised no one has mentioned haproxy <http://haproxy.1wt.eu/> yet. In 
my production setup, I use haproxy in front of Node and Apache. It also 
supports websocket connections. I'm running an app that has an admin 
console that runs on a typical LAMP stack (except the M in my scenario is 
MongoDB), but the client-facing app is an NodeJS app with a real-time 
component that broadcasts data via a websockets connection. A little more 
detail:

In this setup the DNS for the following domains all point to the same IP 
address:

admin.appdomain.com
clientapp.appdomain.com

haproxy is the application listening on port 80. Apache is listening on 
port 3000 and node is listening on port 8000. The websockets IO server is 
listening on port 4000. I have 3 ACLs setup in haproxy to forward requests 
to the appropriate backend based on various conditions. Here's the 
pseudo-config of what's implemented in the haproxy config:

If the host address of the request ends in admin.appdomain.com, forward to 
Apache.
If path of the requested file begins in /io01/, forward to the websockets 
node backend.
All other requests are forwarded to the node client app on port 8000.

Note that in this scenario, the websockets requests and the client app 
requests are on the same domain, so I don't run into CORS issues. haproxy 
can route requests based on request paths, not just domains.

You can also put nginx in between haproxy and your node app in this 
scenario if you want nginx to handle serving static files. Another nice 
thing about haproxy is that if I needed to add more backends (more apache 
servers, more websockets servers, more node servers) and load-balance 
between them, I can do that fairly easily. It will also perform health 
checks on the backends and stop forwarding to them if they are down or 
unresponsive.

There are a ton of different ways to use haproxy, but in this scenario, 
it's kind of an intelligent traffic cop telling requests where to go to get 
served. It's never been the problem of a single failure either.

P.S. - I love haproxy, okay?

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to