在单个EC2实例中运行多个Spring Boot应用程序

时间:2018-03-22 19:56:10

标签: amazon-web-services spring-boot amazon-ec2 dns amazon-cloudfront

我正在尝试在单个EC2实例中部署多个带有嵌入式tomcat的Spring启动Web应用程序。

使用嵌入式tomcat(我更喜欢将我的应用程序运行时解耦),这些应用程序中的每一个都应该在不同的端口上运行(让我们说8081,8082和8083)。

对于这些应用中的每一个,我想指出一个域名:

  • app1.domaine.com应指向APP1在8081上运行
  • app2.domaine.com应指向APP2在8082上运行
  • app3.domaine.com应指向APP3在8083上运行

您是否认为可以继续使用单个实例?

我不确定CloudFront + ELB是否可以解决问题。

1 个答案:

答案 0 :(得分:0)

You can't do this with a Classic Load Balancer, but you can do it with a Application Load Balancer.

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.

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.