【发布时间】:2019-06-24 00:30:18
【问题描述】:
我有一个基于 Angular7 构建的网站,服务器端渲染部署在 Azure 应用服务上。我必须添加一个 web.config 文件才能使 server.js 运行。
这是 web.config 文件
<?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>
<!-- Do not interfere with requests for node-inspector debugging -->
<rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^server.js\/debug[\/]?" />
</rule>
<!-- All other URLs are mapped to the node.js site entry point -->
<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>
此站点已部署到 mysite.com,一切正常。
我现在需要创建一个虚拟目录mysite.com/app 来保存不同的应用程序(在旧的 AngularJS 上)。如果没有服务器端渲染,我只需在 Azure 门户上创建虚拟目录,一切正常。由于服务器端和对 server.js 的“重定向”,虚拟目录不再起作用。
是否有任何规则可以放在 web.config 文件中以忽略 /app 的请求,而不是运行 nodejs 服务器?
【问题讨论】:
标签: node.js angular azure web-config