Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
278 views
in Technique[技术] by (71.8m points)

amazon web services - 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?

question from:https://stackoverflow.com/questions/65878348/deploying-multiple-asp-net-core-apps-in-aws-elastic-beanstalk-on-linux-use-kest

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...