【发布时间】:2019-02-12 11:03:32
【问题描述】:
我试图让多个 Node.js 应用程序在同一个 Azure 应用服务实例中并行工作。我尝试为每个 Node.js 应用程序创建一个虚拟应用程序,但我经常收到服务器错误(代码 500)。我使用 ZipDeploy 或 Azure DevOps 来部署我的应用程序。
我怀疑问题可能是与我的应用程序关联的 web.config 文件不正确。
以下是我的设置的一些详细信息:
在我的应用服务实例的应用程序设置菜单中,我转到虚拟应用程序和目录设置并输入以下内容:
/ site\wwwroot Application x
/mysite1 site\wwwroot\mysite1 Application x
/mysite2 site\wwwroot\mysite2 Application x
我的 wwwroot 目录如下所示。为了确保问题不是来自代码本身,我对所有三个都使用了相同的 Node.js 应用程序:
index.html
server.js
scripts
web.config (*)
----- mysite1
|----- index.html
|----- server.js
|----- scripts
|----- web.config (**)
----- mysite2
|----- index.html
|----- server.js
|----- scripts
|----- web.config (***)
我为他们三个使用默认的 web.config 文件 (provided by Kudu):
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<webSocket enabled="false" />
<handlers>
<add name="iisnode" path="server.js" verb="*" modules="iisnode"/>
</handlers>
<rewrite>
<rules>
<rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^server.js\/debug[\/]?" />
</rule>
<rule name="StaticContent">
<action type="Rewrite" url="public{REQUEST_URI}"/>
</rule>
<rule name="DynamicContent">
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True"/>
</conditions>
<action type="Rewrite" url="server.js"/>
</rule>
</rules>
</rewrite>
<security>
<requestFiltering>
<hiddenSegments>
<remove segment="bin"/>
</hiddenSegments>
</requestFiltering>
</security>
<httpErrors existingResponse="PassThrough" />
</system.webServer>
</configuration>
使用此配置,我可以毫无问题地访问 https://myappservice.azurewebsites.net/,但 https://myappservice.azurewebsites.net/mysite1 仅返回服务器错误。
我尝试按照类似问题中的说明从子目录(** 和 ***)中的 web.config 文件中删除处理程序,但无济于事。
这三个文件的正确配置是什么?我想重写规则需要调整,但我不确定每个规则的确切期望值是多少。
【问题讨论】:
-
您可以接受您的回复作为关闭此问题的答案:)
标签: azure azure-web-app-service iisnode