title: Nginx reverse proxy subdirectory to root
body: <p>So. I am using Nginx as a load balancer to load traffic between couple of instances.</p>
  
  <p>Let's say my Nginx loadbalancer is at platform.staging.com (example).</p>
  
  <p>I am trying to redirect traffic from </p>
  
  <pre><code>platform.staging.com/sync
  </code></pre>
  
  <p>To one of these:</p>
  
  <pre><code>sync1.staging.com:12345
  sync2.staging.com:12345
  </code></pre>
  
  <p>Notice that what I am trying to achieve is to have /sync part stripped down and requests to sync instances should have path /.</p>
  
  <p>This is what I tried but it doesn't work:</p>
  
  <pre><code>upstream sync-cluster {
    ip_hash;
    server sync1.staging.com:12345;
    server sync2.staging.com:12345;
  }
  
  server {
    listen 443 ssl spdy;
    server_name platform.staging.com;
  
    location /sync {
      proxy_pass http://sync-cluster;
    }
  }
  </code></pre>
  
  <p>In the logs I can see:</p>
  
  <pre><code>2014/01/14 23:20:38 [error] 2385#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: XX.XXX.XX.XXX, server: platform.staging.com, request: "GET /sync HTTP/1.1", upstream: "http://X.X.X.XXX:12345/sync", host: "platform.staging.com"
  </code></pre>