I am trying to use S3 bucket to save pdf and image files uploaded by user for my website. I am accessing the S3 data using cloudflare and used setup as mentioned in S3 with Cloudflare disallow direct access and How to serve files from S3 via CloudFlare But if I make the bucket not public then I m not able to access the data. Is there any way to access the S3 data through cloudflare without making the S3 bucket public ?
Asked
Active
Viewed 794 times
1 Answers
1
You can restrict access to your Amazon S3 bucket and objects to only the Cloudflare IP addresses.
Here's how to restrict S3 access to certain IP adresses using a bucket policy.

Dennis Traub
- 50,557
- 7
- 93
- 108
-
Hi Dennis, Thank you for the reply. I have updated the S3 bucket policy as mentioned in the link. But still the issue persist, if the S3 is not made public, still its not accessible even I mention the IP. I am trying to keep the bucket as private only. Is there any option to do it ?. I want to keep the bucket private and access it using cloudflare only β Sreejith Jul 21 '20 at 01:17
-
If you keep it private, no traffic from outside AWS will be allowed. This includes CloudFlare. You have to open it up for it to be accessible by CloudFlare, which is external to AWS. But if you ensure that your bucket policy is tight and secure, it will work. You can think of it like this: You can pull the network cable from a computer to make it secure. But then it is inaccessible from the outside. If you need some access, you must put the cable back in and make sure itβs as secure as possible. And AWS bucket policies help you do that. β Dennis Traub Jul 21 '20 at 07:39
-
Thank you @DennisTraub for the explanation β Sreejith Jul 21 '20 at 09:32