Search code examples
azuredeploymentmeteorconfignitrousio

Path to use in web.config when deploying Meteorjs


Trying to deploy a meteorjs app to Azure, everything looks configured correctly except I'm not sure what to point to:

<?xml version="1.0"?>
<configuration>
  <system.web>
    <compilation batch="false" />
  </system.web>
  <system.webServer>
    <handlers>
      <add name="iisnode" path="server.js" verb="*" modules="iisnode" />
    </handlers>
    <rewrite>
      <rules>
        <rule name="myapp">
              <match url="/*" />
          <action type="Rewrite" url="server.js" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

I do not have a server.js. I am deploying this from nitrous.io, where the app works as expected. Do I need to add a server.js file, and if so, what should be the content? Otherwise, what file is appropriate to point to?


Solution

  • Builded Meteor Application on output has main.js in root folder of your application, you should point your web server onto this file.

    In rewrite rule use regular expression:

    <match url="^(.*)$" ignoreCase="false" />
    

    So your config file will be:

    <?xml version="1.0"?>
    <configuration>
      <system.web>
        <compilation batch="false" />
      </system.web>
      <system.webServer>
        <handlers>
          <add name="iisnode" path="main.js" verb="*" modules="iisnode" />
        </handlers>
        <rewrite>
          <rules>
            <rule name="myapp">
              <match url="^(.*)$" ignoreCase="false" />
              <action type="Rewrite" url="main.js" />
            </rule>
          </rules>
        </rewrite>
      </system.webServer>
    </configuration>
    

    Also do not forget to set ENV variables for builded Meteor: MONGO_URL, ROOT_URL (domain with protocol, like: http://my.site), MAIL_URL, etc.