# Image\_filter before proxy\_store

**URL:** <https://www.ruby-forum.com/t/image-filter-before-proxy-store/168579>\
**Category:** NGINX\
**Created:** [May 22, 2009, 5:29pm UTC](https://www.ruby-forum.com/t/image-filter-before-proxy-store/168579 "2009-05-22T17:29:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Reinis\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/47e85d/32.png) [@Reinis\_R](https://www.ruby-forum.com/u/Reinis_R)\
**Post date:** [May 22, 2009, 5:29pm UTC](https://www.ruby-forum.com/t/image-filter-before-proxy-store/168579/1 "2009-05-22T17:29:20Z")

</div>

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](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](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

---

<div class="post-metadata">

**Author:** ![Reinis\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/47e85d/32.png) [@Reinis\_R](https://www.ruby-forum.com/u/Reinis_R)\
**Post date:** [May 26, 2009, 5:17pm UTC](https://www.ruby-forum.com/t/image-filter-before-proxy-store/168579/2 "2009-05-26T17:17:21Z")

</div>

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](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.
