簡體   English   中英

在 Linux 上的 AWS Elastic Beanstalk 中部署多個 ASP.NET 核心應用程序(使用 Kestrel 服務器)

[英]Deploying Multiple ASP.NET Core apps in AWS Elastic Beanstalk on Linux (Use Kestrel Server)

我在 Visual Studio 解決方案中有兩個 ASP.NET 核心應用程序(API 和 UI),想要部署到 Linux 上的單個 AWS Elastic Beanstalk 並使用 Kestrel 服務器(單個 ZE6B391A8D2C4D45902DZ3A8B 端口) 我怎樣才能做到這一點?

AWS Elastic Beanstalk 支持在 Linux 上的 .NET Core 中運行多個應用程序。 Elastic Beanstalk's .NET Core on Linux documentation contains a helpful section on Bundling applications which includes an example zip file containing two applications to be deployed together on one Elastic Beanstalk instance: dotnet-core-linux-multiple-apps.zip .

您可以將dotnet-core-linux-multiple-apps.zip文件直接部署到 Elastic Beanstalk 以查看其運行情況。 有關如何將 zip 文件部署到 Elastic Beanstalk 的明確說明,請參閱教程 - Linux 上的 .NET Core指南。 在您的情況下,您需要上傳示例dotnet-core-linux-multiple-apps.zip而不是教程引用的單個應用程序 zip。

每個部署的應用程序將在每個應用程序的launchSettings.json文件中定義的本地端口上的 Elastic Beanstalk 應用程序服務器實例上運行。 請注意,此文件在dotnet-core-linux-multiple-apps.zip存檔中包含的任何示例應用程序中都不可見,因為這些應用程序在包含在 zip 文件之前已經使用dotnet publish命令編譯。

告訴 Elastic Beanstalk 哪些路徑到 map 到每個正在運行的應用程序的本地端口的相關配置位於platform/nginx/conf.d/elasticbeanstalk/01_custom.conf文件中,該文件位於dotnet-core-linux-multiple-apps.zip 有關此文件包含的更多信息,請參閱 Linux 代理服務器配置文檔上的 .NET 核心。 請注意,默認情況下,Elastic Beanstalk 將 map /連接到端口5000 ,因此您只需為其他應用程序指定額外的反向代理映射,假設您的一個應用程序配置為在默認端口5000上運行。

所以,總結一下:

  1. 通過查看每個應用的launchSettings.json文件,確保您知道每個應用將在哪個本地端口上運行。

  2. 構建您的每個 .NET 核心應用程序並將它們放在一個文件夾中,您將使用 zip 創建工件以部署到 Elastic Beanstalk。 為了論證起見,我們稱這個文件夾為build

  3. 在您的build文件夾(示例名稱,見上文)中,創建一個platform/nginx/conf.d/elasticbeanstalk/01_custom.conf文件,該文件描述如何將每個應用程序的端口 map 到您想要的路徑。

  4. Zip 在你的“build”文件夾中。 有關此步驟的幫助,請參閱配置應用程序源包文檔

  5. 將您的源包部署到 Elastic Beanstalk。 有關此步驟的幫助,請參閱管理應用程序版本文檔。

暫無
暫無

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

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