Forum: NGINX Image_filter before proxy_store

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Reinis R. (Guest)
on 2009-05-22 19:29
(Received via mailing list)
Hello,
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
proxy_cache_path)).

The basic setup:

server {
    root   /data;

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

    location @small {
                internal;
                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 http://127.0.0.1/small/small_picture.jpg  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.

wbr
rr
Anton Y. (Guest)
on 2009-05-26 19:17
(Received via mailing list)
Reinis R. wrote:
>
> I could of course change the  proxy_pass  to make a request back to for
> example http://127.0.0.1/small/small_picture.jpg  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.

Better to use separate nginx instance for resizing, and proxy_cahce with
proxy_pass to resizer
in main instance.

Resize can block on CPU for relatively long time.
This topic is locked and can not be replied to.