【问题标题】:"You do not have permission to view this directory or page" error in AzureAzure 中的“您无权查看此目录或页面”错误
【发布时间】:2018-09-07 12:48:47
【问题描述】:

我之前从未使用过 Azure,我按照以下教程进行操作:https://docs.microsoft.com/en-us/azure/app-service/app-service-web-get-started-nodejs#create-a-project-zip-file

尝试在 Azure 上部署使用 Node.js 制作的简单应用程序时出现权限错误。我尝试过多次重新上传,但每次都收到相同的错误。我正在使用 Azure 的免费试用版。

这里是 package.json 和 web.config

PACKAGE.JSON:

{
  "name": "oslo-solutions",
  "version": "1.0.0",
  "description": "",
  "main": "scripts.js",
  "scripts": {
    "test": "karma start karma.conf.js",
    "build": "webpack --mode development",
    "start": "webpack-dev-server --open",
    "lint": "eslint src/*.js",
    "jinit": "./node_modules/.bin/jasmine init",
    "npminit": ""
  },
  "repository": {
    "type": "git"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "body-parser": "^1.18.2",
    "bootstrap": "^4.0.0",
    "express": "^4.16.3",
    "jquery": "^3.3.1",
    "lodash": "^4.17.5",
    "popper.js": "^1.14.1"
  },
  "homepage": "/",
  "devDependencies": {
    "babel-core": "^6.26.0",
    "babel-loader": "^7.1.3",
    "babel-preset-es2015": "^6.24.1",
    "clean-webpack-plugin": "^0.1.19",
    "css-loader": "^0.28.10",
    "dotenv-webpack": "^1.5.5",
    "eslint": "^4.18.2",
    "eslint-loader": "^2.0.0",
    "html-webpack-plugin": "^3.0.6",
    "jasmine": "^3.1.0",
    "jasmine-core": "^2.99.0",
    "karma": "^2.0.0",
    "karma-chrome-launcher": "^2.2.0",
    "karma-cli": "^1.0.1",
    "karma-jasmine": "^1.1.1",
    "karma-jasmine-html-reporter": "^0.2.2",
    "karma-jquery": "^0.2.2",
    "karma-webpack": "^2.0.13",
    "style-loader": "^0.20.3",
    "uglifyjs-webpack-plugin": "^1.2.2",
    "webpack": "^4.0.1",
    "webpack-cli": "^2.0.11",
    "webpack-dev-server": "^3.1.1"
  }
}

WEB.CONFIG:

<configuration>
  <system.webServer>

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

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

    <!-- adds index.js to the default document list to allow 
    URLs that only specify the application root location, 
    e.g. http://mysite.antarescloud.com/ -->

    <defaultDocument enabled="true">
      <files>
        <add value="scripts.js" />
      </files>
    </defaultDocument>

  </system.webServer>
</configuration>

【问题讨论】:

  • 你是用cli方案还是去网站
  • 如果您的网站位于 portal.azure.com 中,您可以检查您的文件是否设置正确
  • @Neville Nazarane:是的,我的文件都显示在 portal.azure.com 中。我也向其他人展示了它,他们说它没有理由不工作,所以我认为我的代码中可能缺少一些东西。
  • 之前没用过node.js,但是如果你能做一个基于cli的构建,你可以在命令提示符下试试
  • @Neville Nazarane:我确实使用了基于 Azure cli 的构建。我按照此链接中的教程进行操作:docs.microsoft.com/en-us/azure/app-service/…

标签: azure azure-web-app-service


【解决方案1】:

我按照这个示例 node.js 应用程序:nodejs-docs-hello-world 并将其部署到 azure。它工作正常,请参考web.config 文件:

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

我建议您导航到KUDU url:https://&lt;your app name&gt;.scm.azurewebsites.net/DebugConsole 并转到site\wwwroot 以检查文件是否包含在目录中。

或者暂时放弃zip deploy,直接把本地文件拖到d:home\site\wwwroot目录下再试。

更多解决方案,请参考以下主题:

1.Getting error after pushing to Windows Azure: You do not have permission to view this directory or page

2.https://github.com/Azure-Samples/nodejs-docs-hello-world/issues/9

希望对你有帮助,有什么问题请告诉我。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-02
    • 2021-01-29
    • 2021-01-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多