Difference between revisions of "Node.js on Windows"

From Hostek.com Wiki
Jump to: navigation, search
(Created page with "== Installing Node.js on Windows VPS == #Download and install the Node.js installer (MSI) for Windows: https://nodejs.org/download/ #*Be sure to install the version with the...")
 
m (Codyw moved page Node.js to Node.js on Windows: Reduced scope to Windows only.)
(No difference)

Revision as of 21:23, 28 December 2017

Installing Node.js on Windows VPS

  1. Download and install the Node.js installer (MSI) for Windows: https://nodejs.org/download/
    • Be sure to install the version with the correct bitness of your server. Note that if you have Node.js already installed or the executable already on your server you can skip this step, although you might need to set additional permissions.
  2. Download and install the iisnode module from: https://github.com/Azure/iisnode/downloads
  3. Add "list folder" permissions on c:\home for IIS_USERS. Caution if your hosting multiple applications for various customers you might need to make further security considerations.

Running Your Node.js Application

You should have a domain already created using our control panel WCP. Copy the Node.js application to a the destination folder, where you want to run it. For example: your-domain.com/node, will likely be in

c:\home\your-domain.com\wwwroot\node

You will need to create a web.config and or iisnode.yml file (or modify the existing), see the next section for specifics.

Modify iisnode web.config settings

If you followed the steps to install we suggest getting the example web.config and iisnode.yml from: C:\Program Files\iisnode\www\configuration

NOTE: The iisnode.yml file overrides any iisnode specific settings except for the handler and entrypoint which you are required to include in the web.config.

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

Example web.config

The only thing you'll need to change in this web.config example is moving the path to the node.exe executable and the interceptor. The nice thing about the web.config provided by the example is it details all the available settings. Here's an example web.config:

<configuration>
  <system.webServer>

    <!-- indicates that the hello.js file is a node.js application 
    to be handled by the iisnode module -->

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

    <iisnode
      nodeProcessCommandLine=""%programfiles%\nodejs\node.exe"" 
      interceptor=""%programfiles%\iisnode\interceptor.js""      
      node_env="%node_env%"
      nodeProcessCountPerApplication="1"
      maxConcurrentRequestsPerProcess="1024"
      maxNamedPipeConnectionRetry="100"
      namedPipeConnectionRetryDelay="250"      
      maxNamedPipeConnectionPoolSize="512"
      maxNamedPipePooledConnectionAge="30000"
      asyncCompletionThreadCount="0"
      initialRequestBufferSize="4096"
      maxRequestBufferSize="65536"
      watchedFiles="*.js;iisnode.yml"
      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"
     />

  </system.webServer>
</configuration>

iisnode.yml for configuration

About the iisnode.yml configuration it's importance.