Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CloudFront index.html solution without lambda #22

Open
ehcloninger opened this issue Mar 3, 2024 · 0 comments
Open

CloudFront index.html solution without lambda #22

ehcloninger opened this issue Mar 3, 2024 · 0 comments

Comments

@ehcloninger
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant