I have a bucket with public access blocked that I need to access from nginx running on an EC2 instance.
The EC2 instance profile has the correct access but for nginx to access S3 I would need to pass the credentials on every request. I will investigate nginx caching and the lifetime of the AWS credentials but I wanted to get some thoughts on best practice for this scenario.
Allowing access on the bucket policy level is an option and might be easier.
I have a bucket with public access blocked that I need to access from nginx running on an EC2 instance.
The EC2 instance profile has the correct access but for nginx to access S3 I would need to pass the credentials on every request. I will investigate nginx caching and the lifetime of the AWS credentials but I wanted to get some thoughts on best practice for this scenario.
Allowing access on the bucket policy level is an option and might be easier.
One option is to configure NGINX as an authenticating and caching gateway for AWS S3 which, among other things:
allows you to proxy a private S3 bucket without requiring users to authenticate to it. Within the proxy layer, additional functionality can be configured such as:
- Listing the contents of a S3 bucket
- Providing an authentication gateway using an alternative authentication system to S3
NGINX offers such a gateway configuration at nginxinc/nginx-s3-gateway.