title: Proxy a request - get a parameter from URL, add a header and update request URL using Nginx
body: <p>I am looking for a way to do the following using Nginx:</p>
  
  <ol>
  <li>Intercept a request</li>
  <li>Read URL, parse it and read a value from it.</li>
  <li>Add that value as a new request header</li>
  <li>Update the URL (remove a particular value)</li>
  <li>Forward the request to another server</li>
  </ol>
  
  <p>e.g </p>
  
  <pre><code>Request URL - http://&lt;&lt;nginx&gt;&gt;/test/001.xml/25
  Final URL - http://&lt;&lt;server&gt;&gt;/test/001.xml with header (x-replica: 25)
  </code></pre>
  
  <p>I have a nginx server setup with a upstream for the actual server. I was wondering how do I setup Nginx to achieve this ?</p>