7

Node.js アプリケーションを IIS にデプロイしようとしています。GitHub リポジトリ ( https://github.com/tjanczuk/iisnode/tree/master/src/samples ) でサンプルを見ました。

静的ファイルの提供に行き詰まっています。通常の Node アプリケーションと同様に、パブリックという名前のフォルダーに静的ファイルを保存しました。いくつかのブログ/フォーラムでの提案に従って、次のルールを web.config に追加しました。

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

しかし、うまくいきません。この問題を示すサンプル アプリケーションがあれば、非常に役立ちます。

4

2 に答える 2

10

誰かがGoogleでこの質問に出くわし、受け入れられた回答に記載されているサンプルweb.configに問題があった場合...

これは私のために働いたweb.configファイルです:

<?xml version="1.0" encoding="utf-8"?>  
<configuration>  
    <system.webServer>           
        <handlers>  
            <add name="iisnode" path="server/app.js" verb="*" modules="iisnode" />  
        </handlers>  
        <rewrite>  
            <rules>  
                 <rule name="LogFile" patternSyntax="ECMAScript" stopProcessing="true">  
                      <match url="iisnode" />  
                 </rule>  
                 <rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">                      
                    <match url="^server\/app.js\/debug[\/]?" />  
                 </rule>  
                <rule name="StaticContent" patternSyntax="ECMAScript" stopProcessing="true">
                    <match url=".*" />
                    <action type="Rewrite" url="public/{C:1}" logRewrittenUrl="true" />
                    <conditions>
                        <add input="{REQUEST_URI}" pattern=".*?virtualpath\/(.*)" />
                    </conditions>
                </rule>
                    <rule name="DynamicContent" patternSyntax="ECMAScript">
                    <match url=".*" />
                    <conditions>
                        <add input="{{REQUEST_FILENAME}}" matchType="IsFile" negate="True" />
                    </conditions>
                    <action type="Rewrite" url="server/app.js" logRewrittenUrl="true" />
                </rule>
            </rules>  
       </rewrite>  

        <security>
            <requestFiltering>
                <hiddenSegments>
                    <add segment="node_modules" />
                </hiddenSegments>
            </requestFiltering>
        </security> 
    </system.webServer>  
</configuration>

私のフォルダ構造は次のとおりです。

  • virtualpath/ - IIS で構成された仮想パスを参照します
    • public/ - 静的コンテンツが含まれています
    • server/ - サーバー アプリケーション ファイルが含まれます
于 2015-06-25T08:41:14.827 に答える
5

http://tomasz.janczuk.org/2012/05/yaml-configuration-support-inpublicで、フォルダー内の静的ファイルの要求を Node.js ではなく IIS の静的ファイル ハンドラーにリダイレクトするサンプル iisnode web.config を確認してください。-iisnode.html .

于 2014-06-09T16:38:17.283 に答える