Skip to content

Instantly share code, notes, and snippets.

@booyaa
Created May 20, 2013 17:10
Show Gist options
  • Select an option

  • Save booyaa/5613647 to your computer and use it in GitHub Desktop.

Select an option

Save booyaa/5613647 to your computer and use it in GitHub Desktop.
how to get your existing node.js apps working on azure if you use don't server.js in the root

let's assume that package.json looks like this

{
  "name": "booyaalolwut",
  "version": "6.6.6",
  "description": "witty description here",
  "scripts": {
    "start": "node express/index.js"
},

your existing app starts in express/index.js

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.webServer>
      <handlers>
        <add name="iisnode" path="express/index.js" verb="*" modules="iisnode"/> <!-- change path here-->
     </handlers>
      <rewrite>
           <rules>
                <rule name="StaticContent">
                     <action type="Rewrite" url="public{REQUEST_URI}"/>
                   </rule>
                   <rule name="DynamicContent">
                     <conditions>
                          <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True"/>
                     </conditions>
                    <match url="/*" /> <!-- not sure why this is missing from stock web.config on azure -->
                    <action type="Rewrite" url="express/index.js" /> <!-- change path to script -->
                </rule>
           </rules>
      </rewrite>
   </system.webServer>
 </configuration>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment