title: Nginx forward based on a response from another service
body: <p>I have an nginx setup for reverse proxying into my backend servers. I have a requirement where I need to send the traffic to an IP if it is retrieved from another HTTP request successfully otherwise send it to another IP. 
  Such as I have an incoming request with request_param=abcd(it could be any value). If I am able to retrieve abcd from <a href="http://service/abcd" rel="nofollow noreferrer">http://service/abcd</a>, then route it to IP1, else route it to IP2.</p>
  
  <p>Something like below :</p>
  
  <pre><code>server {
       location /${abcd} {
       if(http://service/$abcd returns HTTP 200)
            then proxy_pass http://$http_host_1$request_uri;
       else
           proxy_pass http://$http_host_2$request_uri;
       ...
      }
  }
  </code></pre>