node + express + iis + iisnode + urlrewrite搭建站点

Posted yue朔

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了node + express + iis + iisnode + urlrewrite搭建站点相关的知识,希望对你有一定的参考价值。

前提条件:安装iis的电脑

准备条件:

1.下载iisnode 地址https://github.com/tjanczuk/iisnode/wiki/iisnode-releases  安装

2.下载URL Rewrite 地址http://www.iis.net/downloads/microsoft/url-rewrite   安装

3.地址 https://www.cnblogs.com/vipp/p/9145932.html,前9步骤搭建node站点

4.新建iis网站,设置如下

开始设置:

在node站点下新建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="index.js" verb="*" modules="iisnode" />
   </handlers>
  
    <!-- use URL rewriting to redirect the entire branch of the URL namespace
    to index.js node.js application; for example, the following URLs will 
    all be handled by index.js:
     
        http://localhost/foo
        http://localhost/bar
         
    -->
  
    <rewrite>
      <rules>
        <rule name="main">
          <match url="/*" />
          <action type="Rewrite" url="index.js" />
        </rule>
      </rules>
    </rewrite>
  
    <!-- exclude node_modules directory and subdirectories from serving
    by IIS since these are implementation details of node.js applications -->
     
    <security>
      <requestFiltering>
        <hiddenSegments>
          <add segment="node_modules" />
        </hiddenSegments>
      </requestFiltering>
    </security>    
     
  </system.webServer>
</configuration>

 

以上是关于node + express + iis + iisnode + urlrewrite搭建站点的主要内容,如果未能解决你的问题,请参考以下文章

如何让 webpack 和 iis express 协同工作?

服务器——IIS——IIS Express——IIS跟IIS Express之间的区别和关系

IIS Express服务器遇到400/503/IIS Express Error的解决办法

IIS/IIS Express中遇到的证书问题

gzip 压缩 & iis express/iis?

给 IIS Express 配置虚拟目录