Home

TBA

View My GitHub Profile

Deploy (electrode) app with iisnode

Related issues: electrode#752

I was able to deploy the sample app with the following configuration:

The configuration below is set for the node app to recide at the root of the site, and on port 80

Steps

  1. Cereate a file on the root of your IIS site called app.js
  2. Configure your web.config. Sample is shown below.
  3. /lib/server/express-server.js /config/default.js Make shure you tell your app to listhen to the right PIPE. The default configuration will cause issues and will always use an integer as defined on by the defaultListenPort.

/app.js

require(__dirname + '\\lib\\server\\index.js');

/web.config

<configuration>
  <system.webServer>

    <!-- SAMPLE 

    Indicates that the app.js file is a node.js application 
    to be handled by the iisnode module -->

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

    <!-- use URL rewriting to redirect the entire branch of the URL namespace
    to app.js node.js application; 
        
    Additional Configuration Ideas
    https://tomasz.janczuk.org/2012/05/yaml-configuration-support-in-iisnode.html
    -->
    
    <rewrite>
      <rules>
          <rule name="LogFile" patternSyntax="ECMAScript" stopProcessing="true">  
                <match url="iisnode"/>  
          </rule>  
          <rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">                      
              <match url="^/app.js\/debug[\/]?" />  
          </rule>  
          <rule name="StaticContent">  
                <action type="Rewrite" url=""/>  
          </rule>  
          <rule name="DynamicContent">  
                <conditions>  
                    <add input="" matchType="IsFile" negate="True"/>  
                </conditions>  
                <action type="Rewrite" url="app.js"/>  
          </rule>
      </rules>
    </rewrite>
        <!-- 
        The key elements are:
          maxNamedPipeConnectionRetry="100" 
          namedPipeConnectionRetryDelay="250"  
        -->
    <iisnode
        maxNamedPipeConnectionRetry="100"
        namedPipeConnectionRetryDelay="250"
    />
  </system.webServer>
</configuration>

/config/default.js

Look for the line that reads

const defaultListenPort = 3000;

Change it to:

const defaultListenPort = process.env.PORT ||  3000;

I tryed addressing this issue on the /config/defaults.js file but had no success.