Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

deliver static content via nginx, proxy node.js jsonrpc requests via nginx and direct access to node.js socket.io

deliver static content via nginx, proxy node.js jsonrpc requests via nginx and direct access to node.js socket.io

Problem

I am just beginner, so my question/architecture could be silly. Please correct me if it is. I need to write an application, that:

  1. Delivers static content (index.html, css, client scripts and images, is handled via nginx only)
  2. Handles jsonrpc api requests (nginx proxies all requests to node.js server)
  3. Handles socket.io connections (i don't see any reason to proxy them via nginx, so i think it should be provided direct connection to node.js application)

Is this possible? So all static requests and jsonrpc are handled using Nginx (and node.js as backend in second case), and socket.io connetions on different port without nginx?

Problem courtesy of: avasin

Solution

Yes - I have developed a couple of node apps with this kind of architecture. In my case I'm substituting Apache for nginx but it's otherwise the same setup you're describing.

The only real gotchas are if you try to use things like Express and templating engines - then you just have to be aware of what you're using in the templates (in node) vs what you're treating as static content.

Solution courtesy of: chsh

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

deliver static content via nginx, proxy node.js jsonrpc requests via nginx and direct access to node.js socket.io

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×