2

A little update to the common question. As of the current version of Nodejs v0.6.5, is it safe to run it as a webserver in production? I really wanna skip the step of using nginx for example for proxy. I am gonna use Expressjs, nowjs, gzippo. And nginx doesnt support websockets yet, and it's a little hard to setup socket.io over ssl. Are there any more benfits to nginx other than that it serves static files better?

Any advice on this matter? And if it's ok to run as a webserver, are there any other modules worth concidering?

Jonas
  • 121,568
  • 97
  • 310
  • 388
georgesamper
  • 4,989
  • 5
  • 40
  • 59
  • Check out the development branch in nginx in 1.1.5 there was a BUGFIX for http 1.1 in http proxy module http://nginx.org/en/CHANGES – Ryan Gibbons Dec 10 '11 at 22:37
  • 1
    In my experience, if you want to run socket.io behind ssl, you need to restrict the transports to just xhr-polling and jsonp-polling. These transports work in every browser and socket.io will even handle the cross domain issue. We had issues with all the other transports. The upside is that if you're using these 2 transports, you can use nginx or some other proxy just fine. – Marco Dec 11 '11 at 06:50

2 Answers2

3

To be honest aside from serving static file I don't really see any important benefits (though Nginx may have more server-specific extensions).

Also you might want to use bouncy or node-http-proxy for proxying and browserify to use you server-side modules on the frontend.

Edit: also you would not be the first using Node without Nginx, as far as I know Trello and other websites are also using it.

alessioalex
  • 62,577
  • 16
  • 155
  • 122
  • Well thats great news :) As it simplifies a lot for me at the moment. And those modules were the last missing pieces of the puzzle. Thanks – georgesamper Dec 10 '11 at 23:14
3

Other benefits of Nginx besides serving static files.

  • You can have it compress dynamically or load up a .gz file even if the non-compressed is reqeusted.
  • You can cache the generation of anything, reducing a call back to node.js.
  • You can have it route to a cluster of node application servers
  • Lots of other neat stuff http://wiki.nginx.org/Modules

Using nginx though isn't required, and running node with nothing in front of it is perfectly fine.

Ryan Gibbons
  • 3,511
  • 31
  • 32
  • "You can have it route to a cluster of node application servers" < you can also do this with bouncy or node-http-proxy. You can also do caching with Node and other stuff that Nginx could do. – alessioalex Dec 10 '11 at 22:44
  • 1
    Yes, but he was asking about benefits of Nginx. Node can do most, if not everything Nginx can. Node is just evented I/O. But having this stuff happen before you application code has to fire and deal with it can be beneficial. With clustering, I'm talking outside just one box. It's very easy to have nginx cluster multiple servers. Yes node can do it too, but you have to write all the handling, checking, etc. – Ryan Gibbons Dec 10 '11 at 22:47
  • 2
    +1 just because you can things in node doesn't mean you should do everything in node! (replace node with language of your choice) – James Butler Dec 10 '11 at 22:58