I having trouble getting iisnode to run my node application.
My directory structure is
iis-site
-client
-server
-server.js
How can I get iisnode to point to a nested .js file? I tried this, but it servers the server.js 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>
I ended up posting this as an issue on the GitHub project and got an answer there.
Basically, the approach is to keep a .js
file in the root of the directory that requires the .js
that bootstraps your application.
Ex:
<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');
I struggled it with 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>
Rewite 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