【问题标题】:How to run a Strapi JS API in IIS with iisnode?如何使用 iisnode 在 IIS 中运行 Strapi JS API?
【发布时间】:2018-11-13 09:45:22
【问题描述】:

我正在尝试使用 iisnode 在 IIS 8.5 中运行 Strapi JS REST API (strapi.io)。但我一直遇到如下 HTTP 状态 500 错误。

  • IIS_IUSRS 组对该目录具有写权限(iisnode 需要);
  • 我使用 dotenv (.env) 文件来指定 production 环境变量;
  • 当我通过执行node server.js 在服务器上独立运行它时,它工作正常。但不是当我通过 IIS Web 应用程序运行它时。

有没有人有一些技巧可以让它工作?任何已知的警告?

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:
(node:4792) DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead.
(node:4792) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.

【问题讨论】:

  • 你找到解决这个问题的方法了吗?我有同样的错误
  • Saeid,我没让它工作。我尝试了下面提到的所有方法,但仍然没有运气。我搬到了 Digital Ocean Ubuntu droplet。

标签: iis-8.5 iisnode strapi


【解决方案1】:

在您的strapi项目文件夹中,转到以下路径并更新。

配置\环境\生产\server.json

{
  "host": "localhost",
  "port": "${process.env.PORT || 8081}",
  "proxy": {
    "enabled": false
  },
  "autoReload": {
    "enabled": false
  },
  "cron": {
    "enabled": false
  },
  "admin": {
    "autoOpen": false
  }
}

web.config

<configuration>
  <system.webServer>
    <handlers>
      <add name="iisnode" path="server.js" verb="*" modules="iisnode" />
    </handlers>
    <rewrite>
      <rules>
        <rule name="yourappname">
          <match url="/*" />
          <action type="Rewrite" url="server.js" />
        </rule>
      </rules>
    </rewrite>
    <iisnode
      node_env="production"
      debuggingEnabled="true"
      nodeProcessCommandLine="&quot;%programfiles%\nodejs\node.exe&quot;" 
      interceptor="&quot;%programfiles%\iisnode\interceptor.js&quot;" />
  </system.webServer>
</configuration>

【讨论】:

  • 还是不行。您使用什么节点版本?文件夹安全性是否有任何其他更改或需要什么?
  • Node v10.15.0, Npm 6.4.1 文件夹必须有“IIS_User”权限才能读写。也许你可以在 cmd 上运行“SET NODE_ENV=production”。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-08-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-01-15
相关资源
最近更新 更多