Nginx proxy to s3 bucket gets 400 Invalid Argument
Posted
by
elssar
on Server Fault
See other posts from Server Fault
or by elssar
Published on 2013-10-23T10:08:06Z
Indexed on
2013/10/24
9:59 UTC
Read the original article
Hit count: 320
I have a Django app in which I serve media files through an nginx proxy to s3.
The relevant python code
response = HttpResponse()
response['X-Accel-Redirect'] = '/s3_redirect/%s' % filefield.url.replace('http://', '')
response['Content-Disposition'] = 'attachment; filename=%s' % filefield.name
return response
The nginx block for the internal redirect is
location ~* ^/s3_redirect/(.*) {
internal;
set $full_url http://$1;
proxy_pass $full_url;
And the request logged by s3 is.
REST.GET.OBJECT <media file> "GET <media file>" 400 InvalidArgument 354 - 4 -
"http://<referer>" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3)
AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.89 Safari/537.1" -
I, for the life of me, can't figure out what's wrong. The url send to nginx by the app is valid, it works in the browser. And nginx is sending a request to s3.
© Server Fault or respective owner