Search code examples
nginxamazon-ecsnginx-configaws-application-load-balancer

ALB with path-based routing for ECS


I have an ALB with path-based routing to an ECS task e.g. if Path is /abc/* forward to ecs-task1

However, now when I browse to www.example.com/abc it returns 404. But if I put index.html in /abc/ folder it works. It seems I need to either copy the files into /abc folder or I need to set the path directory of the webserver to prefix with /abc.

Is there an easy way to achieve path-based routing without having to modify the container so that the ecs task serve requests from the correct folder?


Solution

  • It is not possible with ALB. That would require a path rewrite which is not supported in ALB.

    You can try adding nginx in front and perform the path rewrite there.