Image_filter on error_page location

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.

Also requesting directly from the upstream within the location block:

location ~ /sm_ {
rewrite (.)/sm_(.) $1/$2 break;
image_filter crop 100 100;
proxy_pass http://backend/$uri;
}

works as expected but in this case obviously no local copy (which is
necessary) is made.

Any suggestions?

wbr
rr

Hello!

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

   image_filter   crop  100 100;

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 D.

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.

I see.
Got a feeling that will have to define a seperate 404 location for each
thumbnail block (since there are bunch and all have different
image_filter
params).

rr

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs