I am using NGINX in a unique situation where I and using a reverse proxy for Sonatype Nexus and I only want to cache files if they are larger than, say 10M.
Here is what I have so far:
upstream tunnel_to_nexus_server {
server localhost:28081;
}
proxy_cache_path cache levels=1:2 keys_zone=STATIC:10m inactive=24h max_size=10g;
server {
listen 80;
rewrite ^/nexus$ /nexus/ permanent;
location ~* ^/nexus(.*)$ {
proxy_pass http://tunnel_to_nexus_server $1;
proxy_set_header Host $host;
proxy_buffering on;
proxy_cache STATIC;
proxy_cache_valid 200 3650d;
proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504;
}
location ~* ^/nexus/service/*$ {
expires -1;
add_header 'Cache-Control' 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
}
location ~* ^/nexus/*/repodata/*$ {
expires -1;
add_header 'Cache-Control' 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
}
}
As you can see, I am wanting to almost permanently cache files from Nexus, however I am writing exceptions to the proxy for */repodata/*
and /server/*
paths. But, it would actually be much similar if I could set nginx to only cache if min_size>10M
.
Similar to how I have a max_size=10g
set, I am looking for an equivalent min_size
parameter.