# Lightweight scalable image proxy

**URL:** <https://www.ruby-forum.com/t/lightweight-scalable-image-proxy/124941>\
**Category:** Deployment\
**Created:** [January 3, 2008, 10:00pm UTC](https://www.ruby-forum.com/t/lightweight-scalable-image-proxy/124941 "2008-01-03T22:00:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ericgoodwin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c68b51/32.png) [@ericgoodwin](https://www.ruby-forum.com/u/ericgoodwin)\
**Post date:** [January 3, 2008, 10:00pm UTC](https://www.ruby-forum.com/t/lightweight-scalable-image-proxy/124941/1 "2008-01-03T22:00:14Z")

</div>

I need to proxy images from facebook through a different url (one which  
I can put a crossdomain.xml file)

Im currently using like 20 mongrels where I run:

def index  
return unless params[:url].include?(“[facebook.com](http://facebook.com)”)  
headers[‘Content-Type’] = ‘image/jpeg’  
headers[‘Cache-Control’] = ‘public’  
headers[‘Expires’] = ‘Mon, 28 Jul 2020 23:30:00 GMT’  
open(params[:url]).read  
end

However, this will not scale. Since if hundred people are requesting  
images at the same time, many will get dropped. Im thinking that I could  
do something with apache mod\_proxy but I dont know anything about it.

Im sure for a seasoned deployment guru, this probably like 4 lines of  
code in some apache config file.

Any ideas?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![ericgoodwin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c68b51/32.png) [@ericgoodwin](https://www.ruby-forum.com/u/ericgoodwin)\
**Post date:** [January 3, 2008, 11:44pm UTC](https://www.ruby-forum.com/t/lightweight-scalable-image-proxy/124941/2 "2008-01-03T23:44:52Z")

</div>

nginx

Setup should be fairly simply, and performance will _rock_.

On Jan 3, 1:00 pm, Aryk G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![ericgoodwin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c68b51/32.png) [@ericgoodwin](https://www.ruby-forum.com/u/ericgoodwin)\
**Post date:** [January 3, 2008, 11:46pm UTC](https://www.ruby-forum.com/t/lightweight-scalable-image-proxy/124941/3 "2008-01-03T23:46:39Z")

</div>

On Jan 3, 1:00 pm, Aryk G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> However, this will not scale. Since if hundred people are requesting  
> images at the same time, many will get dropped. Im thinking that I could  
> do something with apache mod\_proxy but I dont know anything about it.

Oh, sorry Aryk, I didn’t see that you mentioned Apache.

mod\_proxy should work quite well.

You may need to reverse proxy these requests as well, not actually  
sure when that’s required.

---

<div class="post-metadata">

**Author:** ![ericgoodwin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c68b51/32.png) [@ericgoodwin](https://www.ruby-forum.com/u/ericgoodwin)\
**Post date:** [January 4, 2008, 12:06am UTC](https://www.ruby-forum.com/t/lightweight-scalable-image-proxy/124941/4 "2008-01-04T00:06:39Z")

</div>

Aryk G. escribiÃ³:

> ```
> open(params[:url]).read
> 
> ```
> 
> Any ideas?
> 
> Thanks in advance.

Hi Aryk, this link about modproxy[1] (see maximum connections and soft  
maximum connections), I guess it help you.

[1][mod\_proxy - Apache HTTP Server Version 2.2](http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypass)

–  
Rafael Garcia Ortega
