S3 VPC endpoint , ALB, Route53 and React SPA in a S3 bucket

84 views Asked by At

So I have a S3 bucket used as static website hosting which contains a React SPA. The bucket name has the name like test.net and index.html has been set up as index and error document.

I also have an alias record in R53 which has the mapping of test.net -> alb which has target group of a S3 VPC endpoint. The intension was to have the website only accessible internally.

So right now whenever I access test.net I can see the index.html from the bucket is being accessed, but when I access /login route, I get 404 from S3 which is expected as I don't have the object inside the bucket. Is it possible to configure ALB listener rules in a way that for 403/404 we redirect to index.html for route parsing?

The above pattern is from https://aws.amazon.com/blogs/networking-and-content-delivery/hosting-internal-https-static-websites-with-alb-s3-and-privatelink/

Previously, I have the similar infra but with CloudFront which has the Error page setting of redirect to /index.html when the response from S3 origin is 403/404. But not sure if it's possible to achieve the same thing but with ALB/S3 VPC endpoint.

Thanks,

0

There are 0 answers