问题描述
我正在尝试在单个EC2实例中部署具有嵌入式tomcat的多个spring boot Web应用程序。
I am trying to deploy multiple spring boot web applications with embedded tomcat in a single EC2 instance.
具有嵌入式tomcat(我更喜欢将应用程序运行时解耦) ,这些应用程序中的每个应用程序都应在不同的端口上运行(例如8081、8082和8083)。
With an embedded tomcat (I prefer to decouple my apps runtime), each one of these apps should be running on a different port (let's say 8081, 8082 and 8083).
对于每个这些应用程序,我都希望指向一个域:
For each of these apps I would like to point a domain:
- app1.domaine.com应该指向运行在8081上的APP1
- app2.domaine。 com应该指向运行在8082上的APP2
- app3.domaine.com应该指向运行在8083上的APP2
您认为可以继续执行单个实例吗?
Do you think it's possible to go ahead with a single instance ?
我不确定CloudFront + ELB是否可以解决问题。
I am not sure if the CloudFront+ELB could do the trick.
推荐答案
您不能使用Classic Load Balancer来做到这一点,但是可以使用Application Load Balancer来做到这一点。
You can't do this with a Classic Load Balancer, but you can do it with a Application Load Balancer.
ALB支持基于主机的路由,因此为每个主机名创建一个路由。每条路由将具有一个关联的目标组,所有3个目标组可以指向同一实例,但指向不同的端口。
ALB supports host-based routing, so create one route for each hostname. Each route will have an associated target group, and all 3 target groups can point to the same instance but different ports.
如果不这样做,则可以对路径执行相同的操作'需要不同的域-即您可以将domaine.com/app1、domaine.com/app2和domaine.com/app3分别与不同的目标组相关联。
You can do the same thing with paths if you don' want different domains - i.e. you can have domaine.com/app1, domaine.com/app2 and domaine.com/app3 each associated with different target groups.
这篇关于在单个EC2实例中运行多个Spring Boot应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!