location / {
proxy_pass http://192.168.1.2:8080/;
}
我下载想把http://192.168.1.2:8080/上面的图片在第一次请求时,都下载到nginx所在磁盘上,下次访问时,直接从nginx取,而不在请求http://192.168.1.2:8080/
我如此配置,发现在指定目录并没有生成缓存文件:
proxy_temp_path /nginx_static/temp;
proxy_cache_path /nginx_static/cache levels=1:2 keys_zone=imgcache:100m inactive=2h max_size=1g;
location ~* ^.+\.(ico|gif|jpg|jpeg|png|bmp)$ {
log_not_found off;
access_log off;
expires 7d;
proxy_pass http://192.168.1.2:8080;
proxy_cache imgcache;
proxy_cache_valid 200 302 1d;
proxy_cache_valid 404 1h;
proxy_cache_valid any 10m;
proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504;
}