问题
I am trying to deploy multiple spring boot web applications with embedded tomcat in a single EC2 instance.
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 should point to APP1 running on 8081
- app2.domaine.com should point to APP2 running on 8082
- app3.domaine.com should point to APP3 running on 8083
Do you think it's possible to go ahead with a single instance ?
I am not sure if the CloudFront+ELB could do the trick.
回答1:
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.
来源:https://stackoverflow.com/questions/49437365/running-multiple-spring-boot-apps-in-a-single-ec2-instance