Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
IISNode Web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<!--
All appSettings are made available to your Node.js app via environment variables
You can access them in your app through the process.env object.
process.env.<key>
-->
<!-- Unconmment the below appSetting if you'd like to use a Virtual Directory -->
<!-- <add key="virtualDirPath" value="" /> -->
</appSettings>
<system.webServer>
<!-- Remove the modules element if running on IIS 8.5-->
<modules runAllManagedModulesForAllRequests="false"/>
<httpErrors existingReponse="PassThrough"></httpErrors>
<iisnode node_env="%node_env%"
nodeProcessCountPerApplication="1"
maxConcurrentRequestsPerProcess="1024"
maxNamedPipeConnectionRetry="100"
namedPipeConnectionRetryDelay="250"
maxNamedPipeConnectionPoolSize="512"
maxNamedPipePooledConnectionAge="30000"
asyncCompletionThreadCount="0"
initialRequestBufferSize="4096"
maxRequestBufferSize="65536"
uncFileChangesPollingInterval="5000"
gracefulShutdownTimeout="60000"
loggingEnabled="true"
logDirectory="iisnode"
debuggingEnabled="true"
debugHeaderEnabled="false"
debuggerPortRange="5058-6058"
debuggerPathSegment="debug"
maxLogFileSizeInKB="128"
maxTotalLogFileSizeInKB="1024"
maxLogFiles="20"
devErrorsEnabled="true"
flushResponse="false"
enableXFF="false"
promoteServerVars=""
configOverrides="iisnode.yml"
watchedFiles="web.config;*.js"
nodeProcessCommandLine="C:\Program Files\nodejs\node.exe"/>
<!--
Before the handlers element can work on IIS 8.5
follow steps listed here https://github.com/tjanczuk/iisnode/issues/52
-->
<handlers>
<add name="iisnode" path="server.js" verb="*" modules="iisnode"/>
<!-- Uncomment below handler if using Socket.io -->
<!--<add name="iisnode-socketio" path="server.js" verb="*" modules="iisnode" />-->
</handlers>
<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" patternSyntax="Wildcard">
<action type="Rewrite" url="public/{R:0}" logRewrittenUrl="true"/>
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
</conditions>
<match url="*.*"/>
</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>
<rule name="SocketIO" patternSyntax="ECMAScript">
<match url="socket.io.+"/>
<action type="Rewrite" url="server.js"/>
</rule>
</rules>
</rewrite>
<directoryBrowse enabled="false"/>
</system.webServer>
</configuration>
@moorthi07

This comment has been minimized.

Copy link

@moorthi07 moorthi07 commented Oct 31, 2015

IISNode lists the source code of the file if your server.js is in different folder (like server/server.js). Even if you put a server.js in the root with require ('\server\server.js') - it doesn't work. Any idea?

@pbaio

This comment has been minimized.

Copy link
Owner Author

@pbaio pbaio commented Feb 25, 2016

Sounds like you need to install the URL ReWrite Module for IIS

@g-aaroncruz

This comment has been minimized.

Copy link

@g-aaroncruz g-aaroncruz commented Jun 13, 2016

When my HTML files reference a CSS or Image file, via a relative path, the application attempts to send a request to "localhost/myapp/css/navbar.css," which leads to a 404 error. Have you ever seen this issue?

@aeciolevy

This comment has been minimized.

Copy link

@aeciolevy aeciolevy commented May 22, 2017

Guys I could not make static content work with iisnode.

This is my web.config

<configuration>
  <system.webServer>


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

    <rewrite>
      <rules>
        <rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
          <match url="^app.js\/debug[\/]?" />
        </rule>

        <rule name="LogFile" patternSyntax="ECMAScript" stopProcessing="true">
          <match url="iisnode"/>
        </rule>

        <rule name="StaticContent" patternSyntax="Wildcard">
                    <action type="Rewrite" url="public/{R:0}" logRewrittenUrl="true"/>
                    <conditions>
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
                    </conditions>
                    <match url="*.*"/>
                </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>

This is the source that I am using to access the scripts:

<script type="text/javascript" src="scripts/app.js"></script>

My server configuration:

app.use(express.static(path.join(virtualDirPath, "public")));

screen shot 2017-05-22 at 11 34 08 am

@megancooper

This comment has been minimized.

Copy link

@megancooper megancooper commented Jul 10, 2017

@pbaio Do you know why 404 errors with POST requests could be occuring using this template? The POST requests are handled in my server.js file

@ves-krd

This comment has been minimized.

Copy link

@ves-krd ves-krd commented May 21, 2018

@pbaio I keep getting 404 errors on transport-polling request from socketio, any ideas?

@gangwar1

This comment has been minimized.

Copy link

@gangwar1 gangwar1 commented Jun 19, 2020

Hi,
I am using the same IISNODE for deploying the Node Express application over iis by using iisnode module.
we are facing one isssue, if any rquest take log time iisnode will return the error response in max 2 min it not wait to complete my request,

Is there any way to increase the rquest timeout on iisnode? if any one have any idea please help me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.