Как запустить API-интерфейс Strapi JS в IIS с помощью iisnode? - PullRequest
0 голосов
/ 13 ноября 2018

Я пытаюсь запустить Strapi JS REST API ( strapi.io ) в IIS 8.5, используя iisnode. Но я продолжаю сталкиваться с ошибками статуса HTTP 500, как показано ниже.

  • Группа IIS_IUSRS имеет права на запись в каталог (требуется для iisnode);
  • Я использую файл dotenv (.env) для указания переменных окружения production;
  • Когда я запускаю его автономно на сервере, выполняя node server.js, он работает нормально. Но не тогда, когда я запускаю его через веб-приложение 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:
(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.

1 Ответ

0 голосов
/ 15 января 2019

В папке проекта Strapi перейдите по нижеуказанным путям и обновите.

config \ сред \ production \ 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>
...