使用Azure Web应用程序服务的Node.js出错
我是Node.js的新手,我在node.js中创建了一个基本应用程序,并尝试在Azure Web App服务上进行部署。
成功部署后,当我尝试访问网站时,它向我显示两种类型的错误,例如您没有权限查看此目录或页面。或网站没有回复。
在这两种情况下,当我尝试跟踪日志时,它会向我显示以下日志中您可以尝试的内容
- 如果您不想启用目录浏览,请确保已配置默认文档并且该文件存在。
- 使用IIS管理器启用目录浏览。
- 打开IIS管理器。
- 在“功能”视图中,双击“目录浏览”。
- 在“目录浏览”页面上的“操作”窗格中,单击“启用”。
- 验证站点或应用程序配置文件中的configuration/system.webServer/directoryBrowse@enabled属性是否设置为true。
我该如何解决错误?
回答如下:你可以尝试这种方法: -
- 在app目录的根目录下创建一个
web.config
文件。 - 将以下代码添加到
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="index.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/ -->
<defaultDocument enabled="true">
<files>
<add value="index.js" />
</files>
</defaultDocument>
</system.webServer>
</configuration>