【问题标题】:Run node.js server with IIS: strange permission behavior使用 IIS 运行 node.js 服务器:奇怪的权限行为
【发布时间】:2021-04-11 03:44:17
【问题描述】:

我有一个简单的 node.js 应用程序在 localhost:3000 上运行,打印“Hello world”。

当我从命令行启动它时,一切正常。

但是当我使用 IIS 启动它时(在 IIS 管理器中选择“浏览网站”),它会出现以下错误:

iisnode encountered an error when processing the request.
HRESULT: 0x2
HTTP status: 500
HTTP subStatus: 1002
HTTP reason: Internal Server Error
You are receiving this HTTP 200 response because system.webServer/iisnode/@devErrorsEnabled configuration setting is 'true'.

In addition to the log of stdout and stderr of the node.exe process, consider using debugging and ETW traces to further diagnose the problem.

The last 64k of the output generated by the node.exe process to stderr is shown below:

Application has thrown an uncaught exception and is terminated:
Error: EPERM: operation not permitted, lstat ...

从 StackOverflow 上的几个问题中,我发现这是一个权限问题。因此,我向该网站的用户授予了完全权限(遵循建议 herehere),但没有成功,同样的错误。

但是当我将应用程序池标识从 ApplicationPoolIdentity 更改为 LocalSystem 时,它可以工作。

我的问题是,这只是一次尝试,我不明白它为什么会起作用。我对此感到困惑,并担心这不是正确的方法。有人能帮我吗?或者解释一下为什么会这样?

【问题讨论】:

    标签: node.js iis


    【解决方案1】:

    这是一个权限问题。 apppool 的默认身份是“ApplicationPoolidentity”,是创建应用程序池时创建的虚拟用户,权限很少。本地系统拥有最高权限。

    一般情况下,Node.js 通过命令行开始监听 3000 端口,IIS 会将请求反向代理到 3000 端口并打印“Hello World”。但是您的描述是从 IIS 开始。我猜你的意思是通过IIS启动node.js,也就是从app pool启动node.js。应用池需要高权限才能启动本地服务,身份必须是“本地系统”。

    如果担心安全问题,最好通过命令行启动node.js,将请求代理到3000端口。通过测试,即使应用池标识为“ApplicationPoolIdentity”也能正常工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-03-02
      • 2012-02-09
      • 1970-01-01
      • 1970-01-01
      • 2021-10-01
      • 2014-04-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多