I have a Java web application that's hosted in Amazon Web Services and it's running on the retired Tomcat 8 with Amazon Linux.
I've attempted to create a new environment to test running the app on the latest Tomcat 8.5 with Corretto 11 running on Amazon Linux 2.
During this process I hit a big problem, within my app it's using a base URL, e.g. https://myserver.com and it's doing some string concatenation to add the path e.g. /rest/myendpoint which of course should be resolved as
https://myserver.com/rest/myendpoint
But unfortunately unknowingly it's being passed through C#'s new URL()
which is appending a trailing slash before the concatenation.
So
https://myserver.com/rest/myendpoint
gets sent to the server as
https://myserver.com/rest//myendpoint
(Note the rest//
should be rest/
)
After deploying the Java war file to the new environment some requests from the app fail with a 404. I've analysed these network logs and of course it's all the URLs that have a double-escape in the path.
As a test in Postman writing the request to have a single slash worked fine, double-quotes failed with a HTTP 404, just like the app.
The problem now is that the app is already used in the wild, we can't change the app because this will involve a long delay (getting it built, app store approval process, then waiting for everyone to upgrade the app), most likely months.
I can't find anything in the AWS portal to configure this.
I did try swapping to Nginx but I experienced the same error.
I did see some people mentioning using .eb-extensions, but the whole apache re-write / mod rules are very foreign to me. In effect I want to re-write any double-slashes after http:// or https:// to single-slashes. Can you please advise on how this could be done?
I'm using the Elastic Beanstalk with Tomcat (currently backed with Apache) with the latest Tomcat Platform version - Tomcat 8.5 with Corretto 11 running on 64bit Amazon Linux 2.
Thank you.