Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Path based routing in AWS ALB to single host with multiple ports

I want to create an ALB which should route my traffic based on path to different websites. For example.

example.com/apple/ should go to 8080

example.com/grapes/ should go to 8180

example.com/oranges/ should go to 8280

Could you please guide me, how can i achieve this.

What i have tried so far is below.

  1. Create listener on port 80 and created different target groups for different port then in rules 80--->8080((If path /apples/) ),80--->8180(If path /grapes/)

But this approach is not working and traffic is only working for default route.

  1. If i create listener for each port like 8080 --?8080(Target group) then my Load balancer URL would be like

LB:PORT/Path/

I do not want port in the URL.

Please help

like image 354
Abhinay Avatar asked Oct 15 '22 11:10

Abhinay


1 Answers

Here is the way to work with path based routing

  • Create Target group ( valid VPC, PORT, Proper health check )
  • Add instance to the target group
  • Go to LB and click on the existing listener
  • Create new Rule and Add the new target group
  • Verify Health check

As I see a similar question many times so posting screens shoot according to above steps.

enter image description here

enter image description here

Edit and add the instances enter image description here

Go to AlB and select listener

enter image description here

Add rule and save

enter image description here

like image 187
Adiii Avatar answered Oct 19 '22 02:10

Adiii