【问题标题】:How To Deploy NodeJS REST API To AZURE Cloud如何将 NodeJS REST API 部署到 AZURE 云
【发布时间】:2018-12-14 22:19:05
【问题描述】:

我正在尝试将我的 nodejs rest api 应用程序部署到我的天蓝色云,但我一次又一次地失败。

我收到 HTTP 500 响应。

“由于发生内部服务器错误,页面无法显示。”

我的 AZURE FTP(我上传的):

web.config 文件

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <webSocket enabled="false" />
    <handlers>
      <add name="iisnode"
           path="app.js"
           verb="*"
           modules="iisnode"/>
    </handlers>
    <rewrite>
      <rules>
        <rule name="NodeInspector"
              patternSyntax="ECMAScript"
              stopProcessing="true">
          <match url="^app.js\/debug[\/]?" />
        </rule>
        <rule name="DynamicContent">
          <conditions>
            <add input="{REQUEST_FILENAME}"
                 matchType="IsFile"
                 negate="True"/>
          </conditions>
          <action type="Rewrite" url="app.js"/>
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

网址

请求:localhost/api/user/getcategories/5c141fa7498f3605c8b2cf34

回应

{
    "success": true,
    "categories": [
        {
            "_id": "5c141fab498f3605c8b2cf35",
            "name": "OTHER"
        }
    ]
}

请求:https://**.azurewebsites.net/api/user/getcategories/5c141fa7498f3605c8b2cf34

响应:由于发生内部服务器错误,页面无法显示。

【问题讨论】:

  • 我通过将 NodeJS 版本添加到“应用程序设置”面板解决了这个问题。 WEBSITE_NODE_DEFAULT_VERSION,8.9.4

标签: node.js rest api azure cloud


【解决方案1】:

如果您访问 Web 应用程序的 Azure 应用程序服务窗格,则在开发工具下应该有一个“高级工具”。选择它,然后点击“go”访问 Kudu。

Kudu Advanced Tools Screenshot

然后您可以转到“调试控制台”下拉菜单来访问您喜欢的 shell。从这里您应该能够访问服务器日志并查看引发了哪些错误。

【讨论】:

    猜你喜欢
    • 2013-08-19
    • 2023-01-17
    • 2022-07-03
    • 1970-01-01
    • 1970-01-01
    • 2015-12-24
    • 2018-06-24
    • 2018-12-02
    • 1970-01-01
    相关资源
    最近更新 更多