Use the Iisnode module to let your node. js app run in Windows system IIS

Source: Internet
Author: User

Recently I prefer to use node. js to do some simple applications, always want to deploy to the production environment, but only one Windows Server 2008 server, and has opened the IIS service, running a lot. NET development site, Port 80 is already occupied.

Originally wanted to use Nginx as a Web server to listen to 80 port, all Web Access to the corresponding IIS and node, but because of the many old sites have been running, so configuration really need a lot of effort, so the whim, can you directly use IIS to host the node service? After a search and found the Iisnode module, can easily solve the problem. The following is to share the actual steps to facilitate the same needs of friends reference.

First Iisnode is an IIS Module that is loaded into IIS after the You can specify some paths in any site via web. config to pass to the node program execution, through the parameter configuration, you can set the number of start node process, as well as the maximum number of connections. And can listen to the site file changes, automatic restart node service and other functions.

Iisnode code is hosted on GitHub, and if you don't want to compile it yourself, you can download the appropriate version directly from the link below.

Https://github.com/tjanczuk/iisnode/wiki/iisnode-releases

For example, my server is a Windows Server 2008 64-bit system, select Download "Iisnode for IIS 7/8 (x64)" Installer

As long as the version is correct, the installation process does not require special attention, you can follow the instructions to complete the steps.

After that, you will need to install the IIS URL Rewrite module (need to use rewrite function to forward related requests to the node service to execute)

: Http://www.iis.net/downloads/microsoft/url-rewrite

After the software installation is complete, create a new Web site in IIS, assign the directory to our Nodejs application directory, and in the final critical step, create a new Web. config profile and write the following:

<configuration>    <system.webServer>        

The function is to forward all requests for the current directory to the node service using the Iisnode module and to specify the execution directory of node. The app.js is the portal file for the node application (which can be modified according to its own directory structure).

Everything is ready, now open the browser to visit the site, you can see the effect.

If the following error occurs when running:

500.19 Configuration Errors This configuration section cannot be used in this path. This behavior occurs if the section is locked at the parent level. The lock is set by default (overridemodedefault= "Deny"), or is explicitly set by a location tag that contains overridemode= "deny" or the old allowoverride= "false".

The following code can be resolved by running CMD:

%windir%\system32\inetsrv\appcmd Unlock Config-section:system.webserver/handlers

One of the handlers is the node name of the error.

In addition, if it is an express project, it is recommended to change the Web. config file to the following

<configuration>    <system.webServer>        

and create a new program entry file Launch.js code as follows:

#!/usr/bin/env noderequire ('./bin/www ');

For this reason please refer to the blog post: Http://heeroluo.net/article/detail/118/suffering-from-iisnode

Use the Iisnode module to let your node. js app run in Windows system IIS

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.