1

我正在尝试使用 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.
4

1 回答 1

2

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

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

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

网络配置

<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>
于 2019-01-15T10:57:53.803 回答