title: nginx proxy_pass dynamic destination
body: <p>Is it possible to configure nginx to query a service (not DNS) to determine the proxy_pass destination based on the currently-requested URI?</p>
  
  <p>For example:</p>
  
  <ol>
  <li>Client requests <a href="http://somesite.tld/somepage" rel="nofollow">http://somesite.tld/somepage</a>, which needs to be proxied.</li>
  <li>nginx connects to the resolving service and sends the request URI which is used to determine the proxy destination.</li>
  <li>The resolving service responds, providing the hostname of the destination.</li>
  <li>The client's request is redirected to the given destination.</li>
  </ol>
  
  <p>If this is not supported, what would be a good way to do this? I could proxy_pass to a resolver+proxy, but would prefer to let nginx handle the proxying directly to the destination. Note that the resolver needs to be queried because the destinations for each URI may change.</p>
  
  <p>Thanks :-)</p>