Copilot-cli: ELB Path mapping to container problem

Created on 6 Jun 2020  Â·  3Comments  Â·  Source: aws/copilot-cli

sh http: path: 'hello'
This is the part of the generated file and I was expecting the container can be accessed via:
http://app-Publi-xxxxxx-xxxxxx.us-west-2.elb.amazonaws.com/hello but got 404. I did add a hello folder at the root of my application and it worked.
My understanding of what happened is that:
http://demo.elb.amazon.com/hello -> http://hello:80/hello
I was expecting something like
http://demo.elb.amazon.com/hello -> http://hello:80

Most helpful comment

Your DNS workaround works better than what I would do if the ELB path works as I expected. Using DNS saved me to create an NGINX service that would act as a proxy for my services.
This is an awesome project and I can't wait for the AWS team's announcement that it is ready for production. Well, technically it can be used in production now!

All 3 comments

Hey hey! Thanks for reaching out, really appreciate it!

Yea, this is an annoying issue. The problem is that ALBs don’t support rewrite rules, so the path forwarded to your service is exactly what the ALB sees.

There aren’t many great options for this but you can:

  • Use a DNS name with your project, and that’ll switch your service to using host based routing. So {app}.{env}.{project}.domainname would be the endpoint, and then because the ALB uses host based routing, your service gets the ‘/‘ path.
  • So a local rewrite of the request

Sorry you ran into this. We’ll keep brainstorming other solutions, too.

Your DNS workaround works better than what I would do if the ELB path works as I expected. Using DNS saved me to create an NGINX service that would act as a proxy for my services.
This is an awesome project and I can't wait for the AWS team's announcement that it is ready for production. Well, technically it can be used in production now!

The CLI is GA now :D David wrote above some workarounds, unfortunately there isn't much that we can do here as this is how ALB works. We reached out to them and they have an existing issue to rewrite requests, if that feature becomes available we'll integrate with Copilot.

Feel free to re-open the issue if you have any other requests!

Was this page helpful?
0 / 5 - 0 ratings