image_filter on error_page location

Maxim Dounin mdounin at mdounin.ru
Tue Jan 3 22:08:19 UTC 2012


Hello!

On Tue, Jan 03, 2012 at 07:18:45PM +0200, Reinis Rozitis wrote:

> Hello,
> I can't figure how to solve such issue - nginx seems not to apply
> image_filter in case the picture comes from upstream via internal
> error_page.
> 
> 
> I have something like (if picture is prefixed with sm_ a dynamic thumbnail is made and the original saved locally):
> 
> location ~ /sm_ {
>        rewrite (.*)/sm_(.*) $1/$2 break;
>        image_filter   crop  100 100;
>        error_page      404 = @store;
> }
> 
> location @store {
>        internal;
>        proxy_pass           http://backend/$uri;
>        proxy_store          on;
> 
> }
> 
> 
> If the file doesn't exist on the server client gets the
> original/full sized image, on the second request when the file is
> stored on the nginx box the image/response gets resized.

This is expected behaviour: you have no image_filter configured in 
location @store, which handles the request if file doesn't exists.

Obvious fix is to add image_filter to location @store, i.e.

    location @store {
        internal;
        proxy_pass    http://backend/$uri;
        proxy_store   on;
        image_filter  crop  100 100;
    }

Maxim Dounin



More information about the nginx mailing list