Image_filter before proxy_store

Reinis Rozitis r at
Fri May 22 19:17:58 MSD 2009

wanted a suggestion on such setup - the idea is to create on-the-fly image resizing and storing the thumbnails on the disk (kinda at 
some level on-demand mirror with file altering and storing them in the same tree as parent host (rather than using 

The basic setup:

server {
    root   /data;

    location ~* (.*)/small_(.*) {
             error_page      404 = @small;

    location @small {
                image_filter   resize  100 100;
                proxy_pass           http://imgstore$1/$2;
                proxy_store          on;

The idea is - if a request http://server/small_picture.jpg  is made and the file doesnt exist on local storage is is passed to a 
parent image store server which holds only 'picture.jpg', resized and stored locally..

The issue is that the 'small_picture.jpg'  (actually the large version) is now saved before the image_filter kicks in and client 
gets the thumbnail only on first request.

I could of course change the  proxy_pass  to make a request back to for example  and then 
define location /small {} which contains the resize and parent proxy_pass definition, but wanted to ask maybe if there is more 
optimal solution rather than making a second request to nginx itself.


More information about the nginx mailing list