Skip to content

Instantly share code, notes, and snippets.

@gansbrest
Created September 18, 2013 17:39
Show Gist options
  • Save gansbrest/6612699 to your computer and use it in GitHub Desktop.
Save gansbrest/6612699 to your computer and use it in GitHub Desktop.
Nginx config to use X-Accel-Redirect to transfer (reproxy) data from Remote servers
location ~* ^/internal_redirect/(.*?)/(.*) {
internal;
# If you use variables in proxy pass you need to
# tell nginx how to resolve your host
# otherwise you will get 502 errors
# you could also use google 8.8.8.8
resolver 172.16.0.23;
proxy_buffering off;
proxy_set_header Content-Length "";
proxy_set_header Cookie "";
proxy_hide_header x-amz-request-id;
proxy_hide_header x-amz-meta-uid;
proxy_hide_header x-amz-id-2;
proxy_hide_header x-amz-meta-mode;
proxy_hide_header x-amz-meta-mtime;
proxy_hide_header x-amz-meta-gid;
proxy_hide_header x-amz-version-id;
proxy_hide_header accept-ranges;
# Do not touch local disks when proxying
# content to clients
proxy_method GET;
proxy_pass_request_body off;
proxy_max_temp_file_size 0;
set $download_host $1;
set $download_uri $2;
set $download_url http://$download_host/$download_uri;
add_header x-by "$instance_id:s3";
proxy_pass $download_url;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment