11

Current setup

Given the following ALB dns:

  • my-alb-dns.com

and the following containers running in ECS:

  • container-a
  • container-b

I configured it in a way that I can route traffic coming through the ALB via path rewriting to the respective service in my ECS cluster:

  • my-alb-dns.com:80/container-a/my/endpoint -> container-a:8080/my/endpoint
  • my-alb-dns.com:80/container-b/my/endpoint -> container-b:8080/my/endpoint

This works fine (by using an nginx) but I was asking myself, if using an additional nginx server is really neccessary to achieve path rewriting. Are there any plans to extend the ALB functionality by custom path-rewrite rules? So far I could not find anything about it in the documentation.

I also took a look at Lamda@Edge but it seems to me a little bit overkill to introduce CloudFront with Lamda just for simple rewriting (which as comparison takes in nginx 1 line of configuration).

Are there any best practices about this or should I keep hoping that AWS will implement it in the distant future and just stick with my current nginx solution?

2 Answers 2

5

ALB doesn't support modifying requests, and I'm not aware of any plans to include such functionality. It's a huge can o' worms, so I'm not surprised AWS is leaving it alone for now. Stick with nginx (or an equivalent, such as haproxy), or modify your application to accept the /container-X prefix in the request path.

2

I use host based routing instead of path based routing in similar situations if your application can support it.

e.g.

service1.mydomain.com -> myalb.com -> tg1 -> container1:8000
service2.mydomain.com -> myalb.com -> tg2 -> container2:8001

Your application will call

service1.mydomain.com

instead of

mydomain.com/service1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.