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:
Make sure you know which local port each of your apps will run on by looking in each app's launchSettings.json
file.
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
.
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.
Zip up your 'build` folder. For help with this step, see the Configure an application source bundle documentation
Deploy your source bundle to Elastic Beanstalk. For help with this step, see the Managing application versions documentation.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…