title: Intercepting backend 301/302 redirects (proxy_pass) and rewriting to another location block possible?
body: <p>We have a couple of backends sitting behind our nginx front ends.</p>
  
  <p>Is it possible to intercept 301 / 302 redirects sent by these backends and have nginx handle them?</p>
  
  <p>We were thinging something alone the lines of:</p>
  
  <pre><code>error_page 302 = @target;
  </code></pre>
  
  <p>But I doubt 301/302 redirects can be handled the same as 404's etc etc... I mean, error_page probably doesnt apply to 200, etc error codes?</p>
  
  <p>So to summarize:</p>
  
  <p>Our backends send back 301/302s once in a while. We would like to have nginx intercept these, and rewrite them to another location block, where we could do any number of other things with them.</p>
  
  <p>Possible?</p>
  
  <p>Thanks!</p>