1

I've set IISNode up on a server, and followed a guide to get a simple hello world node.js app running with it. It works fine and it's externally accessible via the internet. However, when I try to incorporate my existing express app, it's like node/express aren't even there.

This is my web.config file:

<configuration>
<system.webServer>

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

</system.webServer>
</configuration>

That is at the IIS application's root directory, along with app.js which is my main express file. What's interesting is if I go to localhost/TestApp/app.js, I get back:

Cannot GET /TestApp/app.js

However, if I try a different file, like localhost/TestApp/public/htm/index.htm, I get back the file that is located there (in HTML, as expected). Also, if I try and do a server call (e.g. localhost/TestApp/GetUsernames).

What's even more interesting is that if I mess up the port (e.g. app.listen(process.env.PORT2 );), I get this when I try and access localhost/TestApp.js:

> iisnode encountered an error when processing the request.
> 
> HRESULT: 0x2 HTTP status: 500 HTTP reason: Internal Server Error

If the port is correct (app.listen(process.env.PORT2);), I get Cannot GET /TestApp/app.js, so it does look like IISNode is executing app.js (how else would it be failing when I mess up the port), but nothing seems to be working.

How might I fix this, or at least diagnose the problems?

Thank you.

1 Answer 1

3

You probably need to add a <rewrite> section to clarify how to route the requests:

<rewrite>
        <rules>
            <!-- Don't interfere with requests for node-inspector debugging -->
            <rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
                <match url="^server.js\/debug[\/]?" />
            </rule>

            <!-- First we consider whether the incoming URL matches a physical file in the /public folder -->
            <rule name="StaticContent">
                <action type="Rewrite" url="public{REQUEST_URI}" />
            </rule>

            <!-- All other URLs are mapped to the Node.js application entry point -->
            <rule name="DynamicContent">
                <conditions>
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True" />
                </conditions>
                <action type="Rewrite" url="server.js" />
            </rule>
        </rules>
    </rewrite>

Pulled from an example Azure node.js app.

Sign up to request clarification or add additional context in comments.

1 Comment

I am running into similar iisnode issues.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.