如何在不使用 iisnode 的情况下从 IIS/Windows Server Edition 操作系统提供 NodeJS 应用程序? [英] How to serve NodeJS application from IIS/Windows Server Edition OS without using iisnode?

查看:20
本文介绍了如何在不使用 iisnode 的情况下从 IIS/Windows Server Edition 操作系统提供 NodeJS 应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我在具有服务器版操作系统的 Windows 上编写了一个 NodeJS 应用程序,我的应用程序基本上通过使用 NodeJS 子进程执行一些命令来与安装在同一系统中的其他软件进行通信.

在本地主机上一切正常,因为我的服务器有一个静态 IP,我想向公众提供应用程序.如何在不使用 iisnode 的情况下执行此操作?

我尝试使用 iisnode,但从那以后我遇到了问题,我能够为我的站点提供服务器,但是由于 C 驱动器上的一些权限问题,cmd 命令给出了拒绝访问错误.

解决方案

选项 1:

  1. 在本地绑定(例如 http://localhost:8080)上运行您的 Node.js 应用程序 参考
  2. 将 IIS 设置为反向代理 参考

<块引用>

iisnode 提供了对应用程序池集成等更好的控制,但由于它是一个死项目,你绝对不应该再使用它.

选项 2:

使用 HttpPlatformHandler 启动您的 Node.js 应用

<配置><system.webServer><处理程序><add name="httppPlatformHandler";路径=*"动词=*"模块=httpPlatformHandler";资源类型=未指定";/></处理程序><httpPlatform stdoutLogEnabled="true";stdoutLogFile=.
ode.log";启动时间限制=20"processPath=C:Program Files
odejs
ode.exe";参数=.app.js"><环境变量><environmentVariable name="PORT";值=%HTTP_PLATFORM_PORT%";/><environmentVariable name="NODE_ENV";值=生产"/></环境变量></http平台></system.webServer></配置>

参考

So, I've written a NodeJS application on Windows having Server Edition OS, My application basically communicates with other Softwares installed in the same system by executing some commands using NodeJS child process.

Everything is working fine on localhost, as my server has a static IP, I want to serve the application to public. How can I do this without using iisnode?

I tried using iisnode, but I am falling into issues since then, I am able to server my site, but due to some permission issues on C drive, the cmd command gives Access Denied error.

解决方案

Option 1:

  1. Run your Node.js app at a local binding such as http://localhost:8080 Reference
  2. Set up IIS as reverse proxy Reference

iisnode provides better control on application pool integration and so on, but since it is a dead project you definitely shouldn't use it any more.

Option 2:

Use HttpPlatformHandler to launch your Node.js app,

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="httppPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
    </handlers>
    <httpPlatform stdoutLogEnabled="true" stdoutLogFile=".
ode.log" startupTimeLimit="20" processPath="C:Program Files
odejs
ode.exe" arguments=".app.js">
            <environmentVariables>
                <environmentVariable name="PORT" value="%HTTP_PLATFORM_PORT%" />
                <environmentVariable name="NODE_ENV" value="Production" />
            </environmentVariables>
        </httpPlatform>
  </system.webServer>
</configuration>

Reference

这篇关于如何在不使用 iisnode 的情况下从 IIS/Windows Server Edition 操作系统提供 NodeJS 应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆