【问题标题】:Azure AppService NodeJs with virtual directory具有虚拟目录的 Azure 应用服务 NodeJ
【发布时间】: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


    【解决方案1】:

    我收到了另一个 question 的回复(感谢 dana),所以我刚刚添加了规则

    <rule name="ignore app application" stopProcessing="true">
        <match url="^app" />
        <action type="None" />
    </rule>
    

    在其他规则之前。这样,如果输入的 url 是 mysite.com/app,节点服务器将不会被“激活”并且虚拟目录会按预期工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-12-21
      • 2019-12-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-03
      • 1970-01-01
      相关资源
      最近更新 更多