Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm currently hosting my node applications with express (after a simple proxy passes them off)

var httpProxy = require('http-proxy');
var http = require('http');
var express = require('express');

httpProxy.createServer(function (req, res, proxy) {
    var nodeVhosts = ["www.site.com"]
    var host = req.headers['host'];

    var port = nodeVhosts.indexOf(host) > -1
        ? 8080  //must be a node vhost so pass it to :8080
        : 9000; //must be an apache vhost so pass it to :9000

    proxy.proxyRequest(req, res, {host: 'localhost', port: port});
}).listen(8000);

var app = express();
var server = http.createServer(app);

var site = require('./site/app.js').site
app.use(express.vhost('www.site.com', site));

server.listen(8080);

I'm looking to add nginx as the front-end of this machine and wanted to see if I should even use express once I make the switch. In my current configuration I'll use nginx to replace the http proxy part that decides who the vhost belongs to (node or apache). But if I took it one step further and had node web apps hosted w/ nginx instead of express ... would this be a good idea or not?

Also -a little background about my usage of the node web apps. I plan to do full socket.io stuff and express (in it's current form doesn't pass along the upgrade request so node socket.io apps hosted this way always drop back to long polling sadly)

Thank you in advance

share|improve this question
    
I thought http-proxy is currently faster than nginx proxy –  EhevuTov Aug 14 '12 at 19:35
    
Interesting -so in your opinion should I stick with the above instead of adding another web server to the mix? I'm using apache for simple wsgi python apps but wanted a fast socket.io friendly web server for node development (fyi) –  Toran Billups Aug 15 '12 at 0:08
    
I'd try the http-proxy first. DotCloud recently switched from Nginx to http-proxy-based Hipache. See this article: blog.dotcloud.com/announcing-hipache-dotclouds-open-source-webs –  EhevuTov Aug 15 '12 at 0:21

1 Answer 1

Check out Hipache: a distributed HTTP and websocket proxy. It uses http-proxy as a module and does basically what Ngnix does. I'm not 100% sure about performance, but DotCloud recently switched from Nginx.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.