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.
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"?>
<configuration>
<system.webServer>
<handlers>
<add name="httppPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform stdoutLogEnabled="true" stdoutLogFile=".\node.log" startupTimeLimit="20" processPath="C:\Program Files\nodejs\node.exe" arguments=".\app.js">
<environmentVariables>
<environmentVariable name="PORT" value="%HTTP_PLATFORM_PORT%" />
<environmentVariable name="NODE_ENV" value="Production" />
</environmentVariables>
</httpPlatform>
</system.webServer>
</configuration>
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:
- Scott Hanselman wrote about the extension and has a video on it
- Microsoft documentation on using the module
This is a cross post from my own blog.
Top comments (6)
Hi Peter. I was running a web front end virtual machine in Azure , running IIS. The "download the installer" link does not work. Is there an update? Looking for how to get started installing the httpPlatformHandler , maybe something changed? Thank you in advance.
Hi Neil, I tried the link again and I get redirected to the correct page with the extension: iis.net/downloads/microsoft/httppl...
Is this not working for you?
So when you click on the green "Install this extension" button, it takes me just to the gallery - webgallery.microsoft.com/gallery
Further reading looks like they are moving this to Core Net ? Seems like taking something that seemed to be very straightforward into something more complicated to implement. Would love to just be able to find the package to install. Let me know what you find. Or if clicking the green button takes you somewhere different. Thanks!
You can download the installer at the bottom of the page. That is how I installed it. I'm not sure if this extension is still being maintained but it does the job. You are right, I also read that they have moved to another module for .net core: github.com/aspnet/IISIntegration/i...
Oh wow! Thank you. I did not see that, tiny font vs BIG GREEN. Thanks again. Going to try it out tomorrow.
They did a good job trying to hide the installer 😀