3

I am trying to transfer a nodejs app from my development machine to our IIS server. It runs perfectly fine on my machine but I am always getting 404s when I transfer it to IIS.

The directory structure is like so:

C:\Programs Files\iisnode\wwww
└ mysite
  ├ public
  │ ├ app
  │ ├ css
  │ ├ js
  │ └ index.html
  ├ web.config
  └ server.js

When I go to: localhost/node/mysite I get a 404.

Here is the contents of my web.config:

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

        <!-- Tell iisnode where node.exe is located -->
        <iisnode nodeProcessCommandLine="C:/Program Files/nodejs/node.exe"/>

        <!-- Redirect all requests to server.js -->
        <rewrite>
            <rules>
                <rule name="LogFile" patternSyntax="ECMAScript" stopProcessing="true">
                    <match url="^[a-zA-Z0-9_\-]+\.js\.logs\/\d+\.txt$"/>
                </rule>

                <rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
                    <match url="^server.js\/debug[\/]?"/>
                </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>
    </system.webServer>
</configuration>

I tried updating my express routes by prefixing them with node/mysite but that hasn't worked.

I can tell that node is receiving requests because I have it set up to log all requests and there is the following in the log files:

Server started on //.pipe/<some long code>
GET /node/mysite
Lerp
  • 2,957
  • 3
  • 24
  • 43

0 Answers0