http-aws-auth #
Signs proxied requests with AWS Signature Version 4, so nginx can fetch objects from a private S3 bucket. Use it to serve private S3 content through nginx without making the bucket public.
Source: upstream source
Directives
aws_access_key #
syntax: aws_access_key 1 arg (string); · context: http, server, location
Stores a single string value.
aws_endpoint #
syntax: aws_endpoint 1 arg; · context: http, server, location
Overrides the default s3.amazonaws.com endpoint used when signing and proxying requests to a region-specific S3 endpoint.
aws_key_scope #
syntax: aws_key_scope 1 arg (string); · context: http, server, location
Stores a single string value.
aws_s3_bucket #
syntax: aws_s3_bucket 1 arg (string); · context: http, server, location
Stores a single string value.
aws_sign #
syntax: aws_sign no args; · context: http, server, location
Enables AWS Signature V4 signing of the proxied request within the location block.
aws_signing_key #
syntax: aws_signing_key 1 arg (string); · context: http, server, location
Stores a single string value.
Example
server {
listen 8000;
aws_access_key your_aws_access_key; # Example AKIDEXAMPLE
aws_key_scope scope_of_generated_signing_key; #Example 20150830/us-east-1/service/aws4_request
aws_signing_key signing_key_generated_using_script; #Example L4vRLWAO92X5L3Sqk5QydUSdB0nC9+1wfqLMOKLbRp4=
aws_s3_bucket your_s3_bucket;
location / {
aws_sign;
proxy_pass http://your_s3_bucket.s3.amazonaws.com;
}
# This is an example that does not use the server root for the proxy root
location /myfiles {
rewrite /myfiles/(.*) /$1 break;
proxy_pass http://your_s3_bucket.s3.amazonaws.com/$1;
aws_access_key your_aws_access_key;
aws_key_scope scope_of_generated_signing_key;
aws_signing_key signing_key_generated_using_script;
}
# This is an example that use specific s3 endpoint, default endpoint is s3.amazonaws.com
location /s3_beijing {
rewrite /s3_beijing/(.*) /$1 break;
proxy_pass http://your_s3_bucket.s3.cn-north-1.amazonaws.com.cn/$1;
aws_sign;
aws_endpoint "s3.cn-north-1.amazonaws.com.cn";
aws_access_key your_aws_access_key;
aws_key_scope scope_of_generated_signing_key;
aws_signing_key signing_key_generated_using_script;
}
}