Home > Programming, Servers & Scripts > Hosting, Servers & Security

How to Stop Amazon S3 from showing document tree (10)


09-20-2019 01:14 PM #1 eurosen (AMC Alumnus)
How to Stop Amazon S3 from showing document tree

I host my landers on Amazon S3 but when I visit the main page of my bucket it shows a document tree with all files in it.

How do i stop Amazon from showing this?

Thanks.


09-20-2019 05:40 PM #2 micoangelo (Member)

Seconded!


09-20-2019 09:50 PM #3 guriboy007 (Member)

With .htaccess you can't fix it? Create a nope.html page and then add on .htaccess file :


Options -Indexes

ErrorDocument 403 /nope.html
ErrorDocument 404 /nope.html
ErrorDocument 500 /nope.html


09-21-2019 11:24 PM #4 amomaxia (Member)

What's your bucket policy look like?


09-22-2019 08:54 AM #5 eurosen (AMC Alumnus)

This is my current policy:

{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::bucketname.com/*"
}
]
}


09-22-2019 08:55 AM #6 eurosen (AMC Alumnus)

Not sure if this would work as I already have a blank 404 page set up.

I am also not sure if .htaccess works on Amazon S3.


Quote Originally Posted by guriboy007 View Post
With .htaccess you can't fix it? Create a nope.html page and then add on .htaccess file :


Options -Indexes

ErrorDocument 403 /nope.html
ErrorDocument 404 /nope.html
ErrorDocument 500 /nope.html


09-22-2019 06:40 PM #7 rj_insight (Member)

Browse to "access control list" under the permissions tab and look for the public access section ("everyone"). Uncheck all the boxes there and save. Should be good to go.


09-22-2019 06:51 PM #8 eurosen (AMC Alumnus)

Would that not block my landers from being accessed?


09-22-2019 06:56 PM #9 rj_insight (Member)

Quote Originally Posted by eurosen View Post
Would that not block my landers from being accessed?
No, that's what your bucket policy is for.


09-23-2019 02:56 AM #10 eurosen (AMC Alumnus)

Thanks a lot, that did the trick!


Home > Programming, Servers & Scripts > Hosting, Servers & Security