【问题标题】:Can you use node.js with IIS?你可以在 IIS 中使用 node.js 吗?
【发布时间】:2011-04-05 01:56:54
【问题描述】:

这可能是一个非常简单的问题,但是我可以在带有 IIS 的 windows server 2008 环境中使用 node.js 吗?是否有“Microsoft”库或其他更好的解决方案?

【问题讨论】:

标签: windows iis node.js


【解决方案1】:

当然可以,请查看IISNode Project

【讨论】:

    【解决方案2】:

    您可以在 Windows 上安装 Node.js,但它是它自己的服务器,因此除非您使用 IIS 作为它的代理,否则根本不需要 IIS。但请注意,以下内容来自Node.js's installation instructions

    [Windows] 构建都不是令人满意的稳定,但可以运行一些东西。

    【讨论】:

      【解决方案3】:

      您基本上有两条通过 IIS 运行 Node.js 应用程序的途径。

      如果您将整个应用程序专用于 Node.js,并且只需要面向公众的端点来处理您现有的 IIS 应用程序,我建议您使用 ARR 来路由整个站点。我正在为几个项目这样做,并且效果很好。

      老实说,我不喜欢 IISNode,因为您似乎在节点代码与 IIS 中创建了外来端点。它有效,如果您特别针对 Azure,它可能是您的最佳选择。如果您必须将它硬塞到现有的 .Net 应用程序中,它也可能是最佳选择。

      【讨论】:

        【解决方案4】:

        我一直在 Windows 上使用带有 Cygwin 的 Node 并且遇到了一些问题。您可以使用 IIS 在默认端口 80 上提供服务,并在不同的端口上运行您的 Node 应用程序。

        如果你想代理,那么大多数都使用 Nginx。

        【讨论】:

          【解决方案5】:

          您可以在 Windows 上build node.js,但由于可能存在稳定性问题,不建议使用它。如果 IIS 使用基于线程的池,那么您甚至不应该将其用作 node.js 的 reverse proxy(在基于 linux 的系统上通常使用 nginx 来执行此操作),因为池可能很快就会完全加载。如果你想在 Windows 上使用类似于 node.js 的东西,那么你应该尝试查看manos

          【讨论】:

            【解决方案6】:

            我想让它尽可能简单。

            iisnode 的问题

            1. 我安装了 iisnode 并运行示例没有问题,但是...

            2. 我尝试使用 iisnode 在 IIS 上部署它,但我必须捆绑我的流星应用程序,然后将其部署为节点应用程序。我遇到的问题使我灰心。我根本无法安装fibers。编译过程不断出错,所以放弃了。

            反向代理 IIS

            我为解决这个问题所做的是在 IIS 上使用反向代理。

            see my post on meteor forum

            我最后的 web.config 条目是:

            我做了同样的事情,但是,我在 IIS 上使用反向代理的方式 域上的一个子文件夹把我扔了。

            我不知道通过使用 ROOT_URL 我们可以指定一个子 小路。

            例如,如果我在我的流星应用文件夹中运行以下命令:

            set ROOT_URL=http://localhost:3100/n/todos && meteor

            我将能够通过http://localhost:3100/n/todos 访问我的应用程序, 请注意,我省略了尾随的 /。如果我们尝试冲浪到 地址http://localhost:3100/nhttp://localhost:3100/ 将 给我们一个错误Unknown path

            所以,当我第一次设置反向代理时,我每次都收到Unknown Path 错误。

            事实证明,在我的 IIS 配置中,我必须指定 http://localhost:3100/n/todos 作为操作的 url 值,请 注意末尾的 "n/todos"

            所以我的重写规则最终是这样的:[file @ c:/inetpub/wwroot/web.config]

            ```  
            <configuration>
              <system.webServer>
                <rewrite>
                  <rules>
                    <rule name="TODOs meteor app. Route the requests" stopProcessing="true" enabled="true">
                      <match url="^n/todos/(.*)" />
                      <conditions>
                        <add input="{CACHE_URL}" pattern="^(https?)://" />
                      </conditions>
                      <action type="Rewrite" url="{C:1}://localhost:3100/n/todos/{R:1}" /> <!-- I was missing the /n/todos here -->
                      <serverVariables>
                        <set name="HTTP_ACCEPT_ENCODING" value="" />
                      </serverVariables>
                    </rule>
                  </rules>
                  <outboundRules>
                    <rule name="TODOs ReverseProxyOutboundRule1" preCondition="ResponseIsHtml1" enabled="false">
                      <match filterByTags="A, Area, Base, Form, Frame, Head, IFrame, Img, Input, Link, Script" pattern="^http(s)?://localhost:3100/(.*)" />
                      <action type="Rewrite" value="/n/todos/{R:2}" />
                    </rule>
                    <rule name="TODOs RewriteRelativePaths" preCondition="ResponseIsHtml1" enabled="false">
                      <match filterByTags="A, Area, Base, Form, Frame, Head, IFrame, Img, Input, Link, Script" pattern="^/(.*)" negate="false" />
                      <action type="Rewrite" value="/n/todos/{R:1}" />
                    </rule>
                    <rule name="ReverseProxyOutboundRule1" preCondition="ResponseIsHtml1">
                      <match filterByTags="A, Form, Img" pattern="^http(s)?://localhost:3100/(.*)" />
                      <action type="Rewrite" value="http{R:1}://localhost/{R:2}" />
                    </rule>
                    <preConditions>
                      <preCondition name="ResponseIsHtml1">
                        <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
                      </preCondition>
                    </preConditions>
                  </outboundRules>
                </rewrite>
              </system.webServer>
            </configuration>
            ```
            

            谢谢

            【讨论】:

              猜你喜欢
              • 2020-01-29
              • 2016-12-01
              • 2010-09-23
              • 2014-11-13
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 2012-04-03
              • 2013-04-03
              相关资源
              最近更新 更多