title: Rewrite http request based on response location header - Istio
body: <p><strong>Description:</strong></p>
  
  <p>Make a request to Istio (1.0.6) proxy to upstream via virtual_service. Service is responding with header <em>newuri</em>, with <em>httpStatus</em> code ie 307 - I know that redirect should works by designe with 302 and location header. But I want to make a redirect handling based on http error. 
  I tried using <em>envoyFilters</em> with lua but all features are related to stream handling (request/response headers mod) rather than rewrite or request forward . </p>
  
  <p>So the request path looks like this:</p>
  
  <ul>
  <li>client is making request ie curl <a href="http://foo/path" rel="nofollow noreferrer">http://foo/path</a></li>
  <li>proxy is forwarding request to upstream</li>
  <li>upstream is responding with custom header with new_uri ie <a href="http://blabla/path2" rel="nofollow noreferrer">http://blabla/path2</a> as value</li>
  <li>while header exist in response proxy is doing new request to new_uri</li>
  <li>client see response from new_uri</li>
  </ul>
  
  <p>Thanks</p>