2

path-based-routing

I have an alb pointing to my ecs service registered to target-group-one. The DNS of the load balancer works fine and able to print the message from my simple apache webserver. However when I configure path based routing like in the image attached and the add the path to the the DNS url ......com/gci, I get the error message The requested URL was not found on this server.

What am I missing or not doing right?

Paul Whelan
  • 16,574
  • 12
  • 50
  • 83
Theonestar
  • 55
  • 5

1 Answers1

2

If your actual httpd server does not respond to /gci without ALB, then it will not work with ALB. The path rule that you configured only forwards the query to your target group (TG).

So if the rule matches www.example.com/gci, ALB will just forward the query to the associated TG. This means that your ECS service still must correctly respond to /gci path.

In other words, the forwarding rules of ALB do not re-write the paths.

Marcin
  • 215,873
  • 14
  • 235
  • 294
  • Thanks very much @Marcin, I am new to httpd servers, any clue how I can make my server respond to /gci path – Theonestar Mar 14 '21 at 01:32
  • @Theonestar Its application specific. So you have to add such path to your application. But if you don't have it, why would you create rule for it in ALB? – Marcin Mar 14 '21 at 01:33
  • Basically what I am seeking to do is to have the same alb point to one target group based on a certain path and then another target group based on a different path. That way have same alb for multiple services. I am not sure if this is the best way to do it ? – Theonestar Mar 14 '21 at 01:46
  • 1
    @Theonestar You can do this of course, but the applications on the instances must respond correctly to the paths. ALB can't string `/gci` from the request before it forwards it to your instance. For that, you could maybe setup nginx on the instances. So ALB would forward request `/gci` to nginx on the instance, nginx would strip `/gci` and forward the request to your application. But if you can, easier would be to use host routing. So you would use `gci.example.com`, instead of `example.com/gci`. For that you would have to have some domain name in Route53 for example. – Marcin Mar 14 '21 at 02:06
  • ah okay, I see thanks I would look into those options – Theonestar Mar 14 '21 at 02:21
  • @Theonestar How did it go? Any progress? – Marcin Mar 15 '21 at 00:01
  • 1
    sure, I just create a path in my application with the index html that I want serve and from there my app responded to the path and so does the load balancer. Thanks for the tips – Theonestar Mar 16 '21 at 02:44
  • @Marcin can you please look at this question. https://stackoverflow.com/questions/67671252/nginx-static-files-404-with-django-swagger-rest-api I am stuck for 2 days. – Ali Hassan May 25 '21 at 13:17
  • 1
    @AliHassanQureshi Not much of a django expert I am, thus can't help much with new question. Sorry. – Marcin May 26 '21 at 00:00