Deploying a Node.js Server via IIS - How do I run the server?

2.2k views Asked by At

I'm trying to set up a production Node.js server on IIS with the plugin IISnode as specified here: http://www.amazedsaint.com/2011/09/creating-10-minute-todo-listing-app-on.html

What I don't understand is how I run my Server.js file. The example here shows the user links to the hello.js file in the url, but how do I run it as I run my node service locally? I normally just open up a command prompt window and run "nodemon server.js", but IIS has changed the process considerably.

1

There are 1 answers

1
Sebastian K On BEST ANSWER

I believe that the way 'iisnode' works is that it intercepts requests for files with ".js" extension. I do not think it can be set up to run same way as you would run it using node or nodemon.

In my case I set up a production Node.js server with IIS by doing the following:

  1. I set up my port in server.js to run on different port (say 81) so that it does not interfere with IIS.

  2. I set up node to run in a service, so that it auto-restarts when server restarts, console window will not get closed accidently, etc (there are few options you can use - for example http://nssm.cc/ but we wrote our own wrapper service).

  3. I set up forwarding from IIS to that node server - that way I could still use port 80 for the site externally and I was able to use host header filtering (there are multiple sites running on one server)