0

I have a S3 bucket hosting an angular application.

I have an AWS ALB to serve this S3 bucket containing the angular application.

But when I try to request the application through the ALB, it seems that I only can reach the files statically. I get this answer when I try to reach a page which is not directly a file on the bucket.

I've add a record on route53 redirecting on the load balancer (don't try the URL, it's only for the example) :

GET https://mywonderfulwebsite.domainname.tk/pages/2023-info-com

<Error>
  <Code>NoSuchKey</Code>
  <Message>The specified key does not exist.</Message>
  <Key>2023-info-com</Key>
  <RequestId>NDE03SVVQKVVX9CH</RequestId>
  <HostId>DDMYXlkyhzhFDyYuCbCleOUN8TpWxN4MKJHJGU/gLOD9bNM21MiwrUsJYTnwMyEWdJHK6F= 
  </HostId>
</Error>

Of course if I request an existing file on the bucket I get it but without all dynamic elements.

GET https://mywonderfulwebsite.domainname.tk/index.html

#Return a blank page from the site.

I expected to get a fully functional angular app by requesting such URL, did I miss something ?

Matthew
  • 459
  • 2
  • 5
  • 16
  • Your question is confusing. 1. S3 is for static file storage. All you can do with files in S3 is serve them as static assets. 2. A load balancer isn't going to run any code either, it just returns the response it receives from the target. 3. Why even use a load balancer with S3? Do you also have some other targets the load balancer is sending traffic to that are not S3 buckets? 4. Angular is a front-end application framework. The static assets are served to the web browser and then the web browser executes them on the local user's computer. Are there errors in the browser console? – Mark B Apr 13 '23 at 18:19
  • It's a dedicated load balancer to server S3 and it's a the first I do it. My guess was to be able to replace cloudfront distrib by a load balancer, and serve an angular through a S3 instead of cloudfront. After some tests I got a behaviour where I properly get the page index.html but when I request a page which is not an html file on the bucket, I only get a 404. – Matthew Apr 14 '23 at 08:28
  • Why would you want to use a load balancer instead of CloudFront for this? – Mark B Apr 14 '23 at 13:26
  • I've seen that a usual way to build a website is CL->S3 and route53 with a record pointing on the cloudfront. I'd like to make the access more restricted by getting rid of the cloudfront to keep an ALB with a bunch of security groups limiting the access from my VPN network only. Cloudfront is good for publishing a website, but if I want to keep a purely private access ALB looked more adapted. – Matthew Apr 14 '23 at 14:25
  • There are a lot of limitations with ALB serving a static website from S3 however. It doesn't work with any of the "static website" settings in S3. That might be part of the problem you are encountering. – Mark B Apr 14 '23 at 14:28
  • You got the point. That's exactly what I am trying to guess, if it's possible to make it work. – Matthew Apr 14 '23 at 15:03

0 Answers0