【问题标题】:Azure node.js not receiving POST requestsAzure node.js 未收到 POST 请求
【发布时间】:2017-07-27 09:12:22
【问题描述】:

我有一个可以在本地运行的应用程序,但是当我将它部署到 azure POST 请求时会收到 404 响应。各种答案表明我需要编辑我的 web.config,但我看不到需要更改的内容。

如果相关:我的 POST 指向服务器上名为 /receive 的路径,该路径应由 server.js 处理

<?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your Node.js application, please visit
  http://go.microsoft.com/fwlink/?LinkId=290972
  -->
<configuration>
  <appSettings>

    <!--
    <add key="StorageAccountName" value="" />
    <add key="StorageAccountKey" value="" />
    <add key="ServiceBusNamespace" value="" />
    <add key="ServiceBusIssuerName" value="" />
    <add key="ServiceBusIssuerSecretKey" value="" />
    -->
  </appSettings>
  <system.webServer>
    <!-- mimeMap enables IIS to serve particular file types as specified by fileExtension. -->
    <staticContent>
      <mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
    </staticContent>

    <modules runAllManagedModulesForAllRequests="false" />

    <!-- Web.Debug.config adds attributes to this to enable remote debugging when publishing in Debug configuration. -->
    <iisnode watchedFiles="web.config;*.js" />

    <!-- Remote debugging (Azure Website with git deploy): Comment out iisnode above, and uncomment iisnode below. -->
    <!--<iisnode watchedFiles="web.config;*.js" 
      loggingEnabled="true" 
      devErrorsEnabled="true" 
      nodeProcessCommandLine="node.exe &#45;&#45;debug"/>-->

    <!-- indicates that the server.js file is a Node.js application 
    to be handled by the iisnode module -->
    <handlers>
      <add name="iisnode" path="server.js" verb="*" modules="iisnode" />

      <!-- Remote debugging (Azure Website with git deploy): Uncomment NtvsDebugProxy handler below. 
      Additionally copy Microsoft.NodejsTools.WebRole to 'bin' from the Remote Debug Proxy folder.-->
      <!--<add name="NtvsDebugProxy" path="ntvs-debug-proxy/eee3ec35-9835-494f-a07c-dc2f85619df0" verb="*" resourceType="Unspecified" 
        type="Microsoft.NodejsTools.Debugger.WebSocketProxy, Microsoft.NodejsTools.WebRole"/>-->
    </handlers>
    <rewrite>
      <rules>
        <clear />
        <!-- Remote debugging (Azure Website with git deploy): Uncomment the NtvsDebugProxy rule below. -->
        <!--<rule name="NtvsDebugProxy" enabled="true" stopProcessing="true"> 
          <match url="^ntvs-debug-proxy/.*"/> 
        </rule>-->

        <!-- Don't interfere with requests for node-inspector debugging -->
        <rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
          <match url="^server.js\/debug[\/]?" />
        </rule>

        <rule name="app" enabled="true" patternSyntax="ECMAScript" stopProcessing="true">
          <match url="iisnode.+" negate="true" />
          <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
          <action type="Rewrite" url="server.js" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>

  <!-- Remote debugging (Azure Website with git deploy): uncomment system.web below -->
  <!--<system.web> 
    <httpRuntime targetFramework="4.5"/> 
    <customErrors mode="Off"/> 
  </system.web>-->
</configuration>

【问题讨论】:

    标签: node.js azure iis web-config


    【解决方案1】:

    我在我的测试 node.js 应用程序中测试了您的 web.config 文件,一切正常。应该是导致您的问题的任何其他原因。您能否提供有关您的应用程序的更多信息,例如您如何部署到 Azure Web 应用程序,您的结构是什么以及与发布功能相关的任何关键代码 sn-p。这些可能有助于社区发现问题。

    同时,您可以尝试利用 Log Stream 工具在 Azure 应用程序运行时跟踪应用程序的所有信息和标准输出。

    您可以登录您的 Azure 门户,导航到 Azure Apps 刀片,单击 诊断日志 => 启用 应用程序日志记录(文件系统),然后单击 日志流以打开该工具。

    【讨论】:

    • 谢谢,我试试这个。
    • 原来我有一个旧的应用程序副本正在运行。发布并强制重启后,我能够成功发布。诊断日志有很大帮助。
    猜你喜欢
    • 2021-12-25
    • 2015-09-18
    • 2018-07-23
    • 2019-07-04
    • 2014-03-15
    • 1970-01-01
    • 2018-01-02
    • 2016-01-14
    • 2020-11-24
    相关资源
    最近更新 更多