有几个与此相关的问题,但这个用例略有不同。
在Rails中 - 在我的控制器中,我明确设置了响应头:
response.headers['X-Accel-Redirect'] = "some_url"
Nginx配置
location ~* ^/some_url/(.*){
set $s3_bucket '$arg_bucket_name';
set $aws_access_key 'AWSAccessKeyId=$arg_AWSAccessKeyId';
set $url_expires 'Expires=$arg_Expires';
set $url_signature 'Signature=$arg_Signature';
set $url_full '$1?$aws_access_key&$url_expires&$url_signature';
proxy_hide_header Content-Disposition;
add_header Content-Disposition 'attachment; filename=$arg_filename';
proxy_hide_header x-amz-id-2;
proxy_hide_header x-amz-request-id;
proxy_buffering off;
proxy_intercept_errors on;
resolver 4.2.2.2 8.8.8.8 valid=300s;
proxy_pass https://$s3_bucket/$url_full;
}
使用它通过nginx下载100个文件,在少数情况下我收到错误
SignatureDoesNotMatch
The request signature we calculated does not match with the signature you provide.