# Load balancing & local files

**URL:** <https://www.ruby-forum.com/t/load-balancing-local-files/223025>\
**Category:** NGINX\
**Created:** [September 19, 2012, 3:46pm UTC](https://www.ruby-forum.com/t/load-balancing-local-files/223025 "2012-09-19T15:46:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [September 19, 2012, 3:46pm UTC](https://www.ruby-forum.com/t/load-balancing-local-files/223025/1 "2012-09-19T15:46:03Z")

</div>

Hi,

I have 2 servers running Nginx on them while one of them also acts as a  
load  
balancer.  
Each server accesses local unique image files that are generated in  
runtime.

I tried the following configuration for the load balancer nginx:

upstream servername {  
ip\_hash;  
server 127.0.0.1:9000 fail\_timeout=10s;  
server x.x.x.x fail\_timeout=10s;  
}

…

```
location /localimage {
  proxy_pass http://servername;
  root /path/to/localimage;
  expires 7d;
  access_log off;
  break;
}

```

Whenever the request is to server #2, I get the image, when it’s to  
server  
#1 (local) I don’t.  
If I remove the line “proxy\_pass [http://servername](http://servername);” the problem goes  
other  
way around.

What is the correct way to configure nginx to solve this?

Thanks in advance!

Posted at Nginx Forum:

> **[Load balancing & local files](https://forum.nginx.org/read.php?2,230871,230871#msg-230871)**
>
> Hi, I have 2 servers running Nginx on them while one of them also acts as a load balancer. Each server accesses local unique image files that are generated in runtime. I tried the following configuration for the load balancer nginx: upstr
