-
Notifications
You must be signed in to change notification settings - Fork 303
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
Listing of S3 bucket content does not work when using cloudFront #79
Comments
@AshAbc not sure here as I've never tried this route! good luck getting it working and less us know if you succeed. |
For what is worth, I am using this code with Amazon S3 and Cloudfront. However, my S3 is configured for public access. |
@AshAbc did you ever get this to work with CloudFront + Origin Access Identity? |
1 year later i need to get this working too:) |
actually it works for the top bucket directory, but doesn't work when i'm trying to access subdirectories |
@az0 if you have a sec to share a link to your list.html, that'd be really helpful. I'm trying to get this going too, but feel like I'm going in circles. |
I am also on the list of those who try to get it working with CloudFront. |
I also tried with setting up S3 bucket + cloudfront. But using this project, it goes in a loop for me when trying to access index.html file. |
I just got this working for a us-east-1 s3 bucket... Some ideas:
I hope one or more of these ideas helps. |
Hi @haarch does your guideline support CloudFront + ACM ? |
@oguzhanaygn , I'm unsure whether it works with https, as the site I used it for does not require SSL. |
For anyone that hits this problem, I found myself here today. I used a different To be clear I am using a completely private bucket where the only access comes from cloudfront using OAI. From my understanding the reason why my config didn't work is because I set the function pathRewrite(uri) {
if (uri == "/object-list") {
return "/"
}
if (uri == "/" || uri == "") {
return "/index.html"
}
return uri
}
exports.handler = (event, context, callback) => {
const request = event.Records[0].cf.request;
request.uri = pathRewrite(request.uri)
return callback(null, request);
}; Now as I mentioned I used a different project to accomplish my goal. I think something like this: <script type="text/javascript">
// var S3BL_IGNORE_PATH = true;
// var BUCKET_NAME = 'BUCKET';
var BUCKET_URL = 'https://<cloudfront-alais>/object-list';
// var S3B_ROOT_DIR = 'SUBDIR_L1/SUBDIR_L2/';
// var S3B_SORT = 'DEFAULT';
// var EXCLUDE_FILE = 'index.html'; // change to array to exclude multiple files
// var AUTO_TITLE = true;
// var S3_REGION = 's3'; // for us-east-1
</script> would probably do the trick.. Hopefully this helps someone. This is by no means a clean solution 🤷 |
I solved this using an origin response lambda function that embeds the directory listing as variables in the HTML, and editing the javascript to use the built in variables rather than reading them from the bucket.
|
Just got this working via CloudFront + OAI with no changes to the JS besides setting the variables. var S3BL_IGNORE_PATH = true;
var BUCKET_URL = 'https://my.cloudfront.domain'; In CloudFront, I empty out "Default root object". Under behavior I switch to Legacy Cache Settings and choose "All" for Query Strings since CloudFront by default will cut off query strings to the S3 server. Finally, under Origin I set "my-bucket.s3-us-west-2.amazonaws.com", choose OAI. That's about it. |
I am trying to using this code for listing S3 bucket content. Works perfect when s3 content is published directly. However, in my case S3 is not configured direct for public access and is controlled via Origin Access Identity of the cloudFront.
How can I use this when cloudFront is used in front of S3?
The text was updated successfully, but these errors were encountered: