5

私はiisnode githubプロジェクトでもこれを尋ねました

Windows Azure Web サイト経由で IISNode を使用しています。

Node アプリが 2xx ステータス コード (200、201 など) を返す場合、すべて正常であり、期待どおりに動作します。

たとえば、Node アプリが 4xx ステータス コードを返した場合 response.send(404, "not found")(Restify を使用しています)、クライアントに 500 が送信され、本文は単純に「内部サーバー エラーが発生したため、ページを表示できません」となります。

私がそうazure site log tail <sitename>すると、500 がクライアントに送信されると、ログに 404 の HTML が含まれます。

...
<body> 
<div id="content"> 
<div class="content-container"> 
<h3>HTTP Error 404.0 - Not Found</h3> 
<h4>The resource you are looking for has been removed, had its name changed,
or is temporarily unavailable.</h4> 
</div> 
...

IISNode/IIS に 404 を取得してクライアントに送信してもらいたいだけです。これは、401、409 などにも当てはまります。これらはすべて、代わりに 500 が送信される原因となります。

私は自分のweb.configで試し<customErrors mode="off" />てみましたが、役に立ちませんでした。<httpErrors existingResponse="passThrough" />ここに私のweb.configがあります:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.web>
    <customErrors mode="off" />
  </system.web>
  <system.webServer>         
    <httpErrors existingResponse="PassThrough" />
    <staticContent>
       <mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
       <mimeMap fileExtension=".ico" mimeType="image/x-icon" />
    </staticContent>
    <handlers>
      <add name="iisnode" path="server.js" verb="*" modules="iisnode"/>
    </handlers>
    <rewrite>
      <rules>
        <rule name="DynamicContent">
           <conditions>
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True"/>
           </conditions>
           <action type="Rewrite" url="server.js"/>
           <match url="/*" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

価値があるのは、IISnode に何もさせることができず、ノード アプリから 200 を返すことだけです。IIS に静的ファイルを提供させたり、node-inspector を有効にしたり、より興味深い IISNode 機能を実際に実行させようとすると、500 が返されます。理由はわかりませんが、それを乗り越えたいと思っています!

同様の StackOverflow の質問

この質問まさに私の問題です。<httpErrors existingResponse="PassThrough" />それが私にとってはうまくいかないことを除いて。IISNode の設定にもっと根本的な問題があるように感じます。

4

5 に答える 5

3

何らかの理由で、構成の次のセクションがこの問題を引き起こしています:

<staticContent>
    <mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
    <mimeMap fileExtension=".ico" mimeType="image/x-icon" />
</staticContent>

回避策として、可能であればこのセクションを削除して再試行してください。このセクションがこの問題を引き起こしている理由を調査します。

于 2014-03-21T19:45:31.600 に答える
1

Ranjith が指摘したように、staticContentセクションが競合の原因です。これらのエントリをエントリ内に制限できることがわかっlocationたので、必要に応じて IISNode をすべて取得し、静的コンテンツを提供できます。私の web.config は次のようになります。

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.web>
    <customErrors mode="off" />
  </system.web>
  <system.webServer>
    <handlers>
      <add name="iisnode" path="server.js" verb="*" modules="iisnode"/>
    </handlers>
    <rewrite>
      <rules>
        <rule name="Redirect to https" stopProcessing="true">
          <match url="(.*)" />
          <conditions>
            <add input="{HTTPS}" pattern="off" ignoreCase="true" />
          </conditions>
          <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Found" appendQueryString="true" />
        </rule>

        <rule name="StaticContent">
          <action type="Rewrite" url="public{REQUEST_URI}"/>
        </rule>

        <rule name="DynamicContent">
           <conditions>
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True"/>
           </conditions>
           <action type="Rewrite" url="server.js"/>
        </rule>
      </rules>
    </rewrite>
    <httpErrors existingResponse="PassThrough" />
  </system.webServer>

 <location path="public/fonts">
    <system.webServer>
      <staticContent>
         <mimeMap fileExtension=".woff" mimeType="application/font-woff" />
      </staticContent>
    </system.webServer>
  </location>
</configuration>

最後に追加されlocationたエントリは、500 と静的コンテンツの競合を回避します。

于 2014-04-16T13:33:51.917 に答える
0

Azure/IIS からまったく同じ 500 エラー ページが返されます。Azure が自動生成した web.config をベースに、 と を追加<customErrors mode="off" />しまし<httpErrors existingResponse="PassThrough" />た。デフォルトの staticContent ノードも削除しました。何も機能していません。

以下は、Azure にアップロードする web.config です。IIS/iisnode が、node/express がクライアントに返す単純なテキスト エラー メッセージではなく、500 エラー ページを返す原因は何ですか?

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.web>
    <customErrors mode="off" />
  </system.web>
  <system.webServer>
    <httpErrors existingResponse="PassThrough" />
    <webSocket enabled="false" />
    <handlers>
      <add name="iisnode" path="server.js" verb="*" modules="iisnode"/>
    </handlers>
    <rewrite>
      <rules>
        <rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
          <match url="^server.js\/debug[\/]?" />
        </rule>
        <rule name="DynamicContent">
          <conditions>
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True"/>
          </conditions>
          <action type="Rewrite" url="server.js"/>
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>
于 2014-03-25T16:40:36.780 に答える
0

これは私のために働く:

<?xml version="1.0" encoding="utf-8"?> 
  <configuration>
    <system.webServer>
      <handlers>
        <add name="iisnode" path="app.js" verb="*" modules="iisnode"/>
      </handlers>
      <rewrite>
        <rules>
          <rule name="DynamicContent">
            <match url="/*" />
            <action type="Rewrite" url="app.js"/>
          </rule>
        </rules>
      </rewrite>
    </system.webServer>
  </configuration>
于 2014-03-25T17:31:43.050 に答える