簡體   English   中英

在基於 Windows 的 Azure 應用服務上部署服務器端 NodeJS 應用(CI/CD 使用 Azure DevOps)

[英]Deploying server-side NodeJS app on Windows-based Azure App Service (CI/CD Using Azure DevOps)

我們的用例包括以下幾個方面:

  1. Ci/CD 使用 Azure Devops 以確保自動化和監控。
  2. Azure AppService 基於 windows
  3. 我們的 React 項目包括: 前端向服務器端腳本 (server.js) 詢問要嵌入的 url。

server.js 執行一些身份驗證和修改,並在特定時間段內返回單個 url “live”。

使用 npm 在本地站上運行啟動並使用節點啟動服務器當然可以完美運行。

但是在部署到基於 Windows 的 AppService 時,我看不到如何啟動 server.js。

我的 CI 是 npm 安裝和壓縮工件。 CD 正在部署工件並為 index.js web 頁面提供服務。

但我似乎看不到如何啟動 server.js 文件。

感覺我錯過了一些關於 IIS 和 web.config 的重要部分

您可以嘗試在 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>
            <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>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM