iisnode installation & configuration


Recently I am working on Node.js REST API Development & wanted to deploy that on IIS. So here is my configuration steps –

Hardware:

Windows 8 x64 bit

IIS 8.0

Software:

Download IISNode from https://github.com/tjanczuk/iisnode

image

Go to – https://github.com/azure/iisnode/wiki/iisnode-releases

image

Verify

open iis (Start->run->inetmgr)  & Go to Modules

image

You should see following iisnode modules now registered in iis

image

Then I created sample IISNode + Nodejs application. & hosted under defaults site in IIS as below. You should see iisnode modules in that new site as well, else it wont work.

image

Sample code web.config

<configuration>
  <system.webServer>
    <!– indicates that the hello.js file is a node.js application
    to be handled by the iisnode module –>
    <handlers>
      <add name=”iisnode” path=”server.js” verb=”*” modules=”iisnode” />
    </handlers>
    <rewrite>
      <rules>
        <rule name=”api”>
          <match url=”api/*” />
          <action type=”Rewrite” url=”server.js” />
        </rule>
      </rules>
    </rewrite>
    <directoryBrowse enabled=”false” />
    <iisnode
      devErrorsEnabled=”true”
      debuggingEnabled=”true”
      loggingEnabled=”false”
      debuggerPathSegment=”debug”
      nodeProcessCommandLine=”C:\Program Files (x86)\nodejs\node.exe”
      promoteServerVars =”APPL_MD_PATH”>
      <!– NOTE: promote server vars is for middleware : iis-baseUrl which is in middlewares folder–>
    </iisnode>
  </system.webServer>

  <system.web>
    <compilation debug=”true” />
  </system.web>
</configuration>


   

server.js code

var http = require(‘http’);
var port = process.env.port || 1337;
http.createServer(function (req, res) {
res.writeHead(200, { ‘Content-Type’: ‘text/plain’ });
res.end(‘Hello, world! [helloworld sample; iisnode version is ‘ + process.env.IISNODE_VERSION + ‘, node version is ‘ + process.version + ‘]’);
}).listen(port);

Hope this helps… Happy Coding Smile

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s