title: How to redirect to specific upstream servers based on request URL in Nginx?
body: <p>I'm using Nginx as a load balancer for my 5 app servers.</p>
  
  <p>I'd like to redirect to specific servers based on the request URL, for instance:</p>
  
  <pre><code>acme.com/category/*          =&gt; Server #1
  acme.com/admin/*             =&gt; Server #2
  api.acme.com                 =&gt; Server #3
  Fallback for any other URL   =&gt; Server #4, #5
  </code></pre>
  
  <p>My config looks like:</p>
  
  <pre><code>upstream backend  {
    least_conn;
    server 10.128.1.1;
    server 10.128.1.2;
    server 10.128.1.3;
    server 10.128.1.4;
    server 10.128.1.5;
  }
  
  server {
    listen 80;
    server_name _;
  
    location / {
      proxy_set_header Host $host;
      proxy_pass  http://backend;
    }
  }
  </code></pre>
  
  <p>I have no idea how to do this, since I'm not very familiar with Nginx - any one has some clues?</p>