Using HTTP platform handler to host a node.js application via IIS

About a year ago I wrote about hosting a Node.js application via IIS. It uses IIS as a reversed proxy to route traffic from IIS to the node.js webserver. To manage the node.js process pm2 was used. Unfortunately I had some problems restarting the pm2 process when the server restarted. This meant downtime everytime the server was restarted until I manually resurrected pm2.

The original post got a lot of comments and in one of them DavidWhit mentioned that the HTTP Platform handler can be used to manage the node.js process. This IIS module will manage a given process and proxy requests to the process it manages. It acts as a reverse proxy and it manages the process, it's even better than the previous solution. It's not limited to node.js processes, it can manage any process. This also makes it a good solution to host Ruby or other platforms on Windows.

HTTP platform handler schema

I am assuming you already have a node application running, if not please check the previous post to create a simple hello world example.

To install the module, download the installer and run it on your server. This module can only be configured using a web.config, there is no GUI element in the IIS Manager to configure it. Add a web.config in the root of the website if there isn't one yet and copy over this configuration.

<?xml version="1.0" encoding="UTF-8"?>
      <add name="httppPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
    <httpPlatform stdoutLogEnabled="true" stdoutLogFile=".\node.log" startupTimeLimit="20" processPath="C:\Program Files\nodejs\node.exe" arguments=".\app.js">
                <environmentVariable name="PORT" value="%HTTP_PLATFORM_PORT%" />
                <environmentVariable name="NODE_ENV" value="Production" />

You should check if the paths in the configuration file are correct. Once the file has been saved, that's it. If you visit the the URL configured in the bindings in IIS it will now route the traffic to the node.js webserver which will be managed by IIS.

More info: