https proxy s3 aws via nginx with pagespeed

3

I'm trying to setup pagespeed to proxy s3 files via nginx. I want to "save" the files on amazon s3;

The story I want is:

User A
1. nginx serves page to user; and rewrites all https://s3.amazonaws.com/mybucket to https://local.example.com/mybucket
2. browser requests https://local.example.com/mybucket/mypic.jpg
3. nginx takes request; requests file from https://s3.amazonaws.com/mybucket/mypic.jpg
4. nginx caches the response
5. nginx serves the response

User B (after user A)
1-2 are the same
3. nginx serves the cache response

I'm getting really confused by what is need to do so and I haven't found any examples of how to do this. This is what I have been trying; and I'm seeing that I may have to use a downstream cache.

pagespeed MapProxyDomain "https://local.example.com/mybucket/" "https://s3.amazonaws.com/mybucket/";
pagespeed MapRewriteDomain "https://s3.amazonaws.com/mybucket/" "https://local.lawgives.com/mybucket/";

Thank you in advance for the help!

-daniel

Daniel

Posted 2014-06-12T17:24:35.107

Reputation: 163

Answers

1

I gave up using modpagespeed for this and just used nginx

location ~* ^/proxy/s3/s3.amazonaws.com/(.*) {
  proxy_cache one;
  proxy_cache_key $uri;
  proxy_cache_valid 200;
  expires 30m;
  proxy_hide_header x-amz-id-2;
  proxy_hide_header x-amz-request-id;
  proxy_hide_header ETag;
  proxy_hide_header Server;
  add_header s3_proxy_cache $upstream_cache_status;

  proxy_pass http://s3.amazonaws.com/$1;
}

Daniel

Posted 2014-06-12T17:24:35.107

Reputation: 163