Skip to content

Instantly share code, notes, and snippets.

@ruckus ruckus/gist:5819398
Created Jun 20, 2013

Embed
What would you like to do?
nginx: proxy files from S3. Let's masking the URL by pass Expires timestamp as e and Signature as st. For instance the basis URL is https://yourbucket.s3.amazonaws.com/readme.txt?AWSAccessKeyId=YOURONLYACCESSKEY&Signature=sagw4gsafdhsd&Expires=3453445231 Source: https://coderwall.com/p/rlguog
location ~* ^/proxy_private_file/(.*) {
set $s3_bucket 'your_bucket.s3.amazonaws.com';
set $aws_access_key 'AWSAccessKeyId=YOUR_ONLY_ACCESS_KEY';
set $url_expires 'Expires=$arg_e';
set $url_signature 'Signature=$arg_st';
set $url_full '$1?$aws_access_key&$url_expires&$url_signature';
proxy_http_version 1.1;
proxy_set_header Host $s3_bucket;
proxy_set_header Authorization '';
proxy_hide_header x-amz-id-2;
proxy_hide_header x-amz-request-id;
proxy_ignore_headers "Set-Cookie";
proxy_buffering off;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.