Search code examples
amazon-web-servicesamazon-s3single-page-applicationload-balancing

Using an AWS EC2 LoadBalancer as a Reverse Proxy


I have an EC2 Loadbalancer that points to a target group on S3. In that S3 bucket is a file index.html that I can request via "http://myserver.com/index.html". Since this is a SPA I need all path to return that file. ie "http://myserver.com/about" should also return the content of index.html. It should not redirect to that url but really return a http 200 with that content. I guess its the functionality of a reverse proxy. Can I do this with an EC2 LoadBalancer?

I know that this is usually done with AWS CloudFront, but thats not an option for me.


Solution

  • At some point we added a redirect to the Loadbalacer that would redirect a path like myserver.com/about to myserver.com/?redirectPath=about and then let the Angular app do a navigateByUrl([conten of redirectPath]).

    That worked but was also realy bad. We now got the ok for hosting in nginx and everthing is fine.