Node. js + Express on IIS

Source: Internet
Author: User

It means to let the node. js program run in IIS. Refer to this article hosting express node. js applications in IIS using iisnode.

I will refer to this article installing and running node. js applications within IIS on Windows-Are you mad?. It's actually quite clear, but it's just because it's too long.

Wcat (Web capacity analysis tool) has gone. I thought it was over ~~ As a result, the website cannot be run. You need to manually write web. config to add handler, OK, and the Native node program is running. As a result, the website in Express was not running again. After the solution was finally solved, the link was serialized as follows:

  1. Download and install node. Note that the 64-bit version of node is installed under the 64-bit program filesfolder. If you download the 32-bit version, you can directly download node.exe to the 32-bit program files directory and create a new nodejs folder;
  2. Download and install iisnode. If your c: \ Program Files (x86) \ nodejs \ node.exe does not exist, it will report an error and exit. This is the reason why I am prompted for this first step, after installation, the administrator can execute setupsamples in the installation directory. BAT can be immediately experienced, not necessary;
  3. Download and install the URL rewrite package, which is required by express
  4. Publish your node website to IIS, for example, http: // localhost: 8081. the. NET version of the application pool is optional and meaningless.

Do two things after publishing a website:

1. Change the listening port to process. env. port, for example, in Express: app. set ('Port', process. env. port | 3000); in this way, the IIS port can be retained and the node servo website can use a custom port (such as port 3000;

2. Add the Web. config file under the root directory of the website and add the following content:

<configuration> <system.webServer>   <!-- indicates that the hello.js file is a node.js application    to be handled by the iisnode module -->   

In this way, all URLs starting with/are taken over by App. JS, and App. JS is registered as an HTTP handler and the iisnode module is used. At this time, a standard Express can run normally.

 

Finally, I used angular. I just tried to see if the above URL rewrite would take over the angular URL route. The actual test would not. If angular or other frameworks were used for SpA (single-page application) there is no problem with the program because these frameworks are all routed by switching the hash method. It is too late to test if the URL is completely changed by GitHub, And there is time to add the test results.

 

P.s. when we introduced the installation and configuration process above, we talked about the bat program that can be used immediately after iisnode is installed. In fact, we recommend that you execute it, it will generate a node virtual path under the default website, which contains a wealth of examples and instructions, especially the above Web. the Config File also contains many configurable items. The configuration/readme.htm file contains detailed descriptions. We recommend that you perform this operation and read it in detail.

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.