IT:AD:Node.JS:HowTo:Install and use IISNode to host Node.JS within IIS
Process
- Ensure Url-Rewrite extension to IIS is installed: http://www.iis.net/downloads/microsoft/url-rewrite
- Download x64 package from: https://github.com/tjanczuk/iisnode
- Install, but note that 20121022 ran into this error, where it was looking for 32bit version of Node.JS:
The first part of the work around (discussed in this thread is to copy the Node.js files to the target dir to fool the installer)
Then have to read here regarding setting nodeProcessCommandLine to point to real direction.
If you get past that, should be able to proceed with setting up samples, from the command prompt (in admin mode) call %programfiles%\iisnode\setupsamples.bat
then go check that http://localhost/node exists.
I found the install rather rough. Not exactly sure why it started working …
I tried adding the iisnode element to the config file (as per above tip) but it wouldn't take it. I checked in machine.config and then central web.config but saw no mention of it, but it was listed:
After all that, started working. Maybe because I started to use admin more? Who knows…Except that it did.
More hints as what to do (ie, install the x32 and x64 sdk binaries first): http://www.hanselman.com/blog/InstallingAndRunningNodejsApplicationsWithinIISOnWindowsAreYouMad.aspx
Configuration of IISNode
Create an App that uses Node.JS
Update the app's web.config:
<configuration>
<system.webServer>
<handlers>
<add name="iisnode" path="hello.js" verb="*" modules="iisnode" />
</handlers>
</system.webServer>
</configuration>
Or for a whole directory, use location:
<configuration>
<location path="nodejsapps">
<system.webServer>
<handlers>
<add name="iisnode" path="*.js" verb="*" modules="iisnode" />
</handlers>
</system.webServer>
</location>
</configuration>
That points to a node.js ready *.js file:
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello, world! [helloworld sample]');
}).listen(process.env.PORT);
**Important**:
Y
ou can't define the port – you have to tap into what IIS gives you, hence the “process.env.PORT” in the above code snippet.
Resources
* Good early stuff: http://weblogs.asp.net/jgalloway/archive/2011/10/26/using-node-js-in-an-asp-net-mvc-application-with-iisnode.aspx * http://www.hanselman.com/blog/InstallingAndRunningNodejsApplicationsWithinIISOnWindowsAreYouMad.aspx
- Hum….not so hot at handling requests….(2.5 secs slower than IIS itself…)

