Я использую следующую конфигурацию nginx для кэширования ответов s3, я могу получить доступ к s3, но ничего не могу кешировать. Не уверен почему!
proxy_cache_path /var/cache/nginx
levels=1:2 keys_zone=s3_cache:1024m max_size=250g
loader_files=150000 loader_threshold=1s loader_sleep=50ms
inactive=365d use_temp_path=off;
location / {
# Calling aws_auth, to set HTTP Headers
set $s3_host s3.amazonaws.com;
set $s3_uri "/$arg_bucket$uri";
access_by_lua "local aws = require 'resty.aws_auth'; aws.s3_set_headers(ngx.var.s3_host, ngx.var.s3_uri)";
resolver ...;
# Cache related settings
proxy_cache s3_cache;
proxy_cache_valid 200 30d; # 1 month
proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504;
proxy_cache_lock on;
proxy_cache_bypass $http_cache_purge;
# disable convert get to head, otherwise, HEAD request will be denied
proxy_cache_convert_head off;
# disable cache convert requires setting cache key, $request_method is not part of proxy_cache_key by default
proxy_cache_methods GET HEAD;
proxy_cache_key $scheme$request_method$proxy_host$s3_uri;
# This max-age is different from "inactive" in proxy_cache_path.
# It tells the browser or intermediary cache how long the response can be used from the time it was requested.
add_header Cache-Control max-age=2592000;
add_header X-Cache-Status $upstream_cache_status;
# http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_cache_valid
# make sure the response will be cached.
proxy_ignore_headers Set-Cookie Vary;
proxy_pass https://$s3_host$s3_uri;
}
}
error / access.log ничего не сказал в системе. Не уверен, что я что-то упустил.