title: modify HTTP status code of proxy result in nginx
body: <p>I have a nginx reverse proxy serving a web application. This web app returns a <code>302</code> redirect in some cases and I can't change it. However, for some reasons I need to change this returned status to be <code>301</code>.</p>
  
  <p>I tried</p>
  
  <pre><code>proxy_intercept_errors on;
  error_page 302 =301;
  </code></pre>
  
  <p>but obviously this the <code>=301</code> part as the new location. So what I'm looking for would be something like this:</p>
  
  <pre><code>proxy_intercept_errors on;
  error_page 302 =301 $PROXY_HEADER_LOCATION;
  </code></pre>
  
  <p>How can I do this?</p>