[Help] Configuring a Load Balancer with multiple ECS Fargates with custom API paths

0

Hello guys,

I hope you all doing well.

i am using AWS Target groups for a load balance, I know you can set rules based on the path. I would like to make a rule that would take the path "/launch/" and re-route it to a specific ECS and re-write the path to "/api/". However, when I use the "redirect to URL" option, it would then redirect the request to the IP of my ECS which is not what I want to do.

I also need to route the traffic to different ECS depending on the path. So "/launch/" would go to one ECS and "/marketplace/" would go to another.

Additionally, the "launch" need to be removed from the request so it routes correctly. so the request should go from this: Protocol://URL_OF_LOAD_BALANCER_/launch/createNewPost/* To the correct ECS instant without the user seeing the URL change. BUT I need this url to path to change to ../api/createNewPost/* - when it goes to the ECS because thats how the server work.

This logic was done like this because previously the server had a nginx reverse proxy to handle routing between internal servers. so I am hoping to use the load balance as an Nginx Reverse Proxy replacement.

Side Note: If I have a Application Load balance at the front and then route traffic to my ECS, will this actually allow for auto scaling by deploying more containers when the ALB is hitting heavily requested or am I missing more components?

is this possible? and how do I do this with AWS?

2 Answers
0

Hello.

Additionally, the "launch" need to be removed from the request so it routes correctly. so the request should go from this: Protocol://URL_OF_LOAD_BALANCER_/launch/createNewPost/* To the correct ECS instant without the user seeing the URL change. BUT I need this url to path to change to ../api/createNewPost/* - when it goes to the ECS because thats how the server work.

It is operationally possible to redirect the URL with ALB, but I don't think it is possible to prevent the user from seeing the URL change.

is this possible? and how do I do this with AWS?

How about introducing CloudFront before ALB and rewriting the URL with CloudFront Functions?
However, even with CloudFront Functions, I don't think it is possible to prevent users from seeing URL changes.
CloudFront Functions performs processing before requests are made to the ALB.
So, I thought it might be possible to achieve your requirements by rewriting the URL before the request reaches ECS.
https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/example-function-redirect-url.html

If I have a Application Load balance at the front and then route traffic to my ECS, will this actually allow for auto scaling by deploying more containers when the ALB is hitting heavily requested or am I missing more components?

As you know, ALB distributes the load to the running ECS ​​containers.

EXPERT
answered a year ago
  • Unfortunately that wouldn't be a solution as its still exposes the IP. After doing some digging, I found out that this can be a little difficult to implement and I might need to add additionally services to fix this issue.

    So I decided to change my server functionality so it can accept the url with "/launch/" or "/marketplace" and all I have to do it is point it to the correct target. This way it saves me from adding more complicated services to this.

    This is the easiest solution and fastest but I wanted to check experiment with AWS before going back to my code and solving it from there. Just trying improving my AWS skills!

0

To anyone who is looking for an answer to this problem, I unfortunately did not find a solution that is provided by AWS. However, I changed my server so it accepts the "/launch/" and "/marketplace/" prefixes so it functions well. This is the easiest option to simplify the aws implementation and reduce costs as introducing more services will only increase the cost.

Going to leave this post active for few days in case the AWS geniuses see it and help us out and help any wondering souls of the future.

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions