0

I am receiving the following error with a 403 error code when I try to navigate to my Azure website.

You do not have permission to view this directory or page.

I've created the proper seed app files (I believe) listed below, and am confused why I am still running into this error. I don't see anything suspicious on the application logs.

Logs:

Command: "D:\home\site\deployments\tools\deploy.cmd"
Handling node.js deployment.
KuduSync.NET from: 'D:\home\site\repository' to: 'D:\home\site\wwwroot'
Copying file: 'server.js'
The package.json file does not specify node.js engine version constraints.
The node.js application will run with the default node.js version 6.9.1.
Selected npm version 3.10.8
npm WARN test@1.0.0 No description
Finished successfully.

Files:

server.js:

var express = require('express');
var app = express();

var PORT = process.env.PORT || 1337;

app.get('/', function (req, res) {
  res.send('Hello World!!')
});

app.listen(PORT, function () {
  console.log('App listening on port ' + PORT);
});

package.json:

{
  ...,
  "scripts": {
    "start": "node server",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  ...
}

web.config:

<configuration>
  <system.webServer>
    <handlers>
      <!-- indicates that the app.js file is a node.js application to be handled by the iisnode module -->
      <add name="iisnode" path="server.js" verb="*" modules="iisnode" />
    </handlers>
  </system.webServer>
</configuration>
sir_thursday
  • 5,270
  • 12
  • 64
  • 118

1 Answers1

3

Your web.config tells IIS to use iisnode module for server.js path, however all other paths including website root will not be affected by this.

If you want your node application to be available on your azure website root, you need to explicitly tell IIS about this:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.webServer>
        <handlers>
            <add name="iisnode" path="server.js" verb="*" modules="iisnode" />
        </handlers>
        <rewrite>
            <rules>
                <rule name="DynamicContent">
                    <match url="/*" />
                    <action type="Rewrite" url="server.js"/>
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>
Egor Laufer
  • 86
  • 2
  • 4