【问题标题】:IISNode - IIS7.0 - Invalid web.config issue on Windows 2008 R2IISNode - IIS7.0 - Windows 2008 R2 上的无效 web.config 问题
【发布时间】:2017-06-14 09:04:06
【问题描述】:

我正在尝试使用 IISNode 模块将 node.js 应用程序部署到托管在 Windows 2008 机器上的 IIS 7.0。我有以下 web.config 文件 -

<configuration>
    <system.webServer>
    <webSocket enabled="false" />
    <handlers>
       <add name="iisnode" path="build/index.js" verb="*" modules="iisnode"/>
    </handlers>
    <rewrite>
       <rules>
        <!-- Do not interfere with requests for node-inspector debugging -->
        <rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
           <match url="^build\/server.js\/debug[\/]?" />
        </rule>

        <rule name="StaticContent">
           <action type="Rewrite" url="public{REQUEST_URI}"/>
        </rule>

        <!-- All other URLs are mapped to the node.js site entry point -->
        <rule name="DynamicContent">
            <conditions>
              <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True"/>
            </conditions>
            <action type="Rewrite" url="build/index.js"/>
        </rule>
      </rules>
    </rewrite>

<security>
  <requestFiltering>
    <hiddenSegments>
      <remove segment="bin"/>
    </hiddenSegments>
  </requestFiltering>
</security>
<httpErrors existingResponse="PassThrough" /></system.webServer></configuration>

当我导航到该站点时,它给出了一个 HTTP 错误 500.19 内部服务器错误,抱怨 web.config 无效。这个确切的配置在 azure wep 应用程序上运行没有任何问题。我还安装了 Rewrite 模块。

如果有人遇到此问题并提供任何帮助,我们将不胜感激。

非常感谢。

已编辑 - 问题出在以下行 -

<webSocket enabled="false" />

删除解决了问题。但是在尝试访问该站点时出现以下错误 -

iisnode 无法在 node.exe 进程终止之前建立命名管道连接

【问题讨论】:

    标签: node.js iis iisnode


    【解决方案1】:

    这个 web.config 怎么样?

      <configuration>
    <rewrite>      
    <rules>
        <!-- First we consider whether the incoming URL matches a physical file in the /public folder -->
        <rule name="StaticContent">
          <action type="Rewrite" url="public{REQUEST_URI}"/>
        </rule>
    
        <!-- All other URLs are mapped to the node.js site entry point -->
        <rule name="DynamicContent">
          <conditions>
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True"/>
          </conditions>
          <action type="Rewrite" url="build/index.js"/>
        </rule>
      </rules>
    </rewrite>
    
    <!-- 'bin' directory has no special meaning in node.js and apps can be placed in it -->
    <security>
      <requestFiltering>
        <hiddenSegments>
          <remove segment="bin"/>
        </hiddenSegments>
      </requestFiltering>
    </security>
    
    <!-- Make sure error responses are left untouched -->
    <httpErrors existingResponse="PassThrough" />
    
    <!--
      You can control how Node is hosted within IIS using the following options:
        * watchedFiles: semi-colon separated list of files that will be watched for changes to restart the server
        * node_env: will be propagated to node as NODE_ENV environment variable
        * debuggingEnabled - controls whether the built-in debugger is enabled
    
      See https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/web.config for a full list of options
    -->
    <!--<iisnode watchedFiles="web.config;*.js"/>-->
      </configuration>
    

    【讨论】:

    • 不知何故,web.config 内容没有在帖子中正确复制。我已经更新了帖子以反映我正在使用的实际 web.config - 这与您在此处发布的类似。
    • 处理程序标签&lt;handlers&gt; &lt;add name="iisnode" path="hello.js" verb="*" modules="iisnode" /&gt; &lt;/handlers&gt;在哪里
    • 感谢您指出 - 我已将其添加并更新了帖子。
    • 你的节点服务器的端口是多少? @RaviB。
    • 在 54123 上 - 我需要在 web.config 中指定吗?
    【解决方案2】:

    在我的情况下,基本上最后一个问题是权限问题 - 我必须将 IIS_Users 组完全控制到节点应用程序文件夹,它对我有用。

    谢谢。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-07-29
      • 1970-01-01
      • 1970-01-01
      • 2013-03-27
      • 1970-01-01
      • 1970-01-01
      • 2014-09-12
      • 1970-01-01
      相关资源
      最近更新 更多