简体   繁体   中英

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

I have two ASP.NET Core Apps (API and UI) in Visual Studio solution, want to deploy to a single AWS Elastic Beanstalk on Linux and use Kestrel server (single URL and different ports). How can I accomplish this?

AWS Elastic Beanstalk supports running multiple apps in .NET Core on Linux. 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 .

You can deploy the dotnet-core-linux-multiple-apps.zip file directly to Elastic Beanstalk to see it running. For explicit instructions on how to deploy a zip file to Elastic Beanstalk, see the Tutorial - .NET Core on Linux guide. In your case, you'll want to upload the example dotnet-core-linux-multiple-apps.zip instead of the single app zip that the tutorial references.

Each deployed application will run on the Elastic Beanstalk application server instances on the local ports defined in each application's launchSettings.json file. Note that this file is not visible in either of the example apps contained inside the dotnet-core-linux-multiple-apps.zip archive because those apps were already compiled with the dotnet publish command before being included in the zip file.

The relevant configuration that tells Elastic Beanstalk which paths to map to each running app's local ports is inside the platform/nginx/conf.d/elasticbeanstalk/01_custom.conf file, located inside the dotnet-core-linux-multiple-apps.zip . See the .NET Core on Linux proxy server config documentation for more info on what this file contains. Note that Elastic Beanstalk will, by default, map / to port 5000 , so you only need to specify additional reverse proxy mappings for your other apps, assuming one of your apps is configured to run on the default port 5000 .

So, to sum up:

  1. Make sure you know which local port each of your apps will run on by looking in each app's launchSettings.json file.

  2. Build each of your .NET Core apps and put them together in one folder which you will zip to create the artifact to deploy to Elastic Beanstalk. For the sake of argument, let's call this folder build .

  3. In your build folder (example name, see above), create a platform/nginx/conf.d/elasticbeanstalk/01_custom.conf file which describes how to map each app's ports to your desired paths.

  4. Zip up your 'build` folder. For help with this step, see the Configure an application source bundle documentation

  5. Deploy your source bundle to Elastic Beanstalk. For help with this step, see the Managing application versions documentation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM