How many uri / backend mappings do you have? You could perform the above in two straight forward location blocks, based on the uri. location /abc { proxy_pass http://host01:8080; } .... Posted at Nginx Forum: http://forum.nginx.org/read.php?2,194480,194616#msg-194616