I am trying to use AWS API Gateway as a reverse HTTP proxy to front several prototype web applications which are deployed as elastic beanstalk apps:
Each EB app is mapped in API Gateway under it's app name e.g.
/hello1 (API Gateway mapping) --> prototype1 EB application
/hello2 (API Gateway mapping) --> prototype2 EB application
... etc
This is the overall mapping I have created:
It seems that API Gateway treats requests for the root resource in each mapping e.g. '/' differently to requests for sub resources, so I have set up proxy mappings for both:
The root ('/') resource is a straight forward (i.e. non-greedy) proxy mapping:
Then there's a greedy proxy mapping for anything underneath the root context:
I then deploy the API to a stage named 'master'
The idea being that to access each prototype I'd GET the URL http://protos.acme.com/<stage>/<proto_name>
e.g. http://protos.acme.com/master/hello1
.
I'm finding that if I add a trailing slash to the URL, or specify a particular resource e.g. index.html
then everything works perfectly e.g.
However if I omit the trailing slash from the URL e.g. http://protos.acme.com/master/hello1
then the URL rewriting done by API Gateway stops working and any URLs in the proxied content no longer resolve correctly as they omit the prototype name e.g. http://protos.acme.com/master/index.html
.
I can't find any way to configure the behaviour for when the trailing slash is omitted and I don't think it's acceptable to force my users to always remember the trailing slash.
Grateful for any insight!
Edd
I setup a quick test and it seems to work if I explicitly define a GET
method at the resource root path in addition to the ANY
{proxy+}
path.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With