Welcome to weblogs.com.pk Sign in | Join | Help

Staging Node Application on Windows

Staging Node Application

We can run a Node Application on Windows with IIS; there exists IISNODE that can be used to do exactly this. Simply install Node and IISNode on the server

Create a folder on the file system and an IIS Application Pool for the Node Application. Give IIS APPPOOL\Pool-Name user full access to the folder!

Setup a web site or a virtual folder for our Node application choosing the newly created Application Pool

Create a simple hello.js; making sure that http server is started at process.env.PORT and not some hard coded value. IISNODE will set the environment variable PORT and by default it uses Named Pipes. Create a web.config adding iisnode handler in its configuration/system.webServer/handlers to handle %web%/hello.js requests

We can access our Hello World Node application at http://web-path/hello.js; IIS will automatically spins up node.exe; and we can even change the application file and IISNode picks up the changes and recycle node.exe processes. No special arrangements like GIT Hook / PM2 restarts required.

http://web-path/hello.js is not a good looking URL; we would like to have simply http://web-path and our hello.js should respond. For this we can use Url Rewrite extenstion, once installed, simply add configuration/system.webServer/rewrite section in the web.config to rewrite all the /* requests to hello.js and we will have the desired result. With this arrangement in place we can now run Express.js apps easily!

Resources

Published Friday, June 03, 2016 3:09 PM by khurram

Comments

No Comments

New Comments to this post are disabled