nginx proxy_pass to different backends based on location / passing rewrited url

view story

http://serverfault.com – What the quickest and cleanest solution if you want to proxy URL request to two different backends via proxypass based on location. location /app1/ { alias /var/www/ruby/public; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; try_files $uri $uri/ @ruby; } location @ruby { proxy_pass; } location /app2/ { proxy_set_header X-Real-IP $remote_addr; proxy_set_ (HowTos)