我正在尝试设置 pagespeed 以通过 nginx 代理 s3 文件。我想将文件“保存”在 amazon s3 上;
我想要的故事是:
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
我对需要做什么感到很困惑,而且我还没有找到任何如何做到这一点的示例。这就是我一直在尝试的;我发现我可能必须使用下游缓存。
pagespeed MapProxyDomain "https://local.example.com/mybucket/" "https://s3.amazonaws.com/mybucket/";
pagespeed MapRewriteDomain "https://s3.amazonaws.com/mybucket/" "https://local.lawgives.com/mybucket/";
提前感谢您的帮助!
-丹尼尔
答案1
我放弃使用 modpagespeed 了,直接用 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;
}