Load balancing & local files

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;” the problem goes
other
way around.

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

Thanks in advance!

Posted at Nginx Forum: