Point iisnode in the server.js file nested in the folder on the iis site

I am having trouble getting the iisnode of my node app running. My directory structure

iis-site
   -client
   -server
      -server.js

      

How can I get iisnode to point to the attached .js file? I tried this but it is server.js server instead of executing it.

<handlers>
    <add name="iisnode" path="server\server.js" verb="*" modules="iisnode" />
</handlers>

      

and

<rule name="default">
       <match url="/*" />
        <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
        <action type="Rewrite" url="server/server.js" />
</rule>

      

+2


source to share


2 answers


I ended up posting this as an issue on the GitHub project and got it.

Basically, the approach is to store the file .js

in the root of the directory it requires .js

, which your application loads.

Example:

<handlers>
    <add name="iisnode" path="iisnode.js" verb="*" modules="iisnode" />
</handlers>

      



and

<rule name="default">
       <match url="/*" />
        <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
        <action type="Rewrite" url="iisnode.js" />
</rule>

      

and in iisnode.js

there is one line of code:require(__dirname + '\\server\\server.js');

+4


source


I struggled with this a bit and here is my solution without any additional file

Handler

<handlers>
        <add name="iisnode" path="dist/index.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/7afabecd-23d0-4ac1-a682-c36ef59e1480" verb="*" resourceType="Unspecified"
          type="Microsoft.NodejsTools.Debugger.WebSocketProxy, Microsoft.NodejsTools.WebRole"/>-->
</handlers>

      

Change rule



<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>-->
            <rule name="app" enabled="true" patternSyntax="ECMAScript" stopProcessing="true">
                <match url="iisnode.+" negate="true"/>
                <conditions logicalGrouping="MatchAll" trackAllCaptures="false"/>
                <action type="Rewrite" url="dist/index.js"/>
            </rule>
        </rules>

      

So as you can see my app entry point is in dist / index.js

Gabor

+1


source







All Articles