1

I am trying to fetch static files from s3 bucket in case of 502 error.

This is how I have configured nginx for requests :

error_page 502 = @static;
location / {
  index index.php;
  try_files $uri $uri/ /index.php;
# return 502;
  proxy_intercept_errors on;
}

location @static{
  rewrite ^/name/(.*) ^/bucket_name/$1 break;
  proxy_pass http://s3.amazonaws.com;
}

The 502 error is sent when nginx can't handle huge load.

Now when I uncomment 'return 502' statement and comment try_files statement, everything is fine, and the data is correctly served by s3 bucket.

But when for the above given code, when I increase the load on website using loader.io (I have checked that it generates 502 error), the browser receives 403 error(403 Forbidden).

And this kind message is displayed on browser,

<Error>
  <Code>AccessDenied</Code>
  <Message>Access Denied</Message>
  <RequestId>some_string</RequestId>
  <HostId>
    something
  </HostId>

And when I uncomment 'return 502' and comment 'try_files statement' and increase the load, s3 still serves files correctly.

Any idea, why am I receiving 403 error due to heavy load but no such error when manually return 502? Also, is there any other alternative style to fetch data from s3 bucket in case of heavy load(502 error)? Also are 502 errors sent manually and due to heavy load same?

2
  • 1
    That 403 error is being generated by S3. Your object permissions or bucket policy is incorrect or insufficient, or you are sending an improperly-formed request. The second ^ in the rewrite should probably not be there at all, and http://s3.amazonaws.com/bucket_name/ is only valid for buckets in the US-Standard region. Aug 23, 2015 at 3:27
  • I won't say the request could be wrong, because the file is successfully accessed when 502 is sent manually(mentioned in question).
    – Satys
    Aug 23, 2015 at 4:49

0

You must log in to answer this question.

Browse other questions tagged .