noobgallery icon indicating copy to clipboard operation
noobgallery copied to clipboard

CloudFront index.html solution without lambda

Open ehcloninger opened this issue 11 months ago • 0 comments

I tried to use noobgallery but kept running into dependency issues in node. I'll probably look for something else. However, I have a solution perhaps to the CloudFront issue you mention about requiring index.html. In fact, I wrote it up in a blog post several years ago on my site...

If you look at the comments on this page, you’ll find a comment by someone named ‘ash1’. This is the correct answer…


I found a much simpler solution that doesn’t require a lambda. In your Cloud distribution, for the origin, instead of using the S3 bucket, use the S3 “endpoint url”. That will automatically take care of the subdirectory default index.html issues. Changed all of my distributions, and they are all working now with subdirectory “/” endpoints going to the index.html files within the subdirectory.

   Go to S3, click on your bucket,
   Click on properties tab.
   Click on Static Website Hosting
   At the top of the static website hosting page, it will show you the endpoint url for your S3 bucket. Use that url value for the CF distribution origin instead of the name of your S3 bucket.

To be clear on this, in the “Origin settings” page for your CloudFront distribution, change the “Origin Domain Name” from something like mysite.com.s3.amazonaws.com to mysite.com.s3-website-us-east-1.amazonaws.com.

Once I made this change and allowed CloudFront to re-deploy my site, I was able to click on links to pages within the site.

ehcloninger avatar Mar 03 '24 17:03 ehcloninger