title: reverse proxy legacy server so requests for /style go to correct server
body: <p>We have a large number of very old legacy servers were trying to put a proxy &amp; firewall in front of.  Due to the large number were trying to avoid having to change each server's code and make changes purely from the proxy if at all possible.  We have a proxy which routes to a server based off of the url.  so a request to <a href="http://proxy/server1/" rel="nofollow noreferrer">http://proxy/server1/</a>... would be sent to <a href="http://server1/" rel="nofollow noreferrer">http://server1/</a>...  </p>
  
  <p>Our problem is that the code on the servers will make a request requests for elements at /style and /image etc.  These end up as requests to <a href="http://proxy/style" rel="nofollow noreferrer">http://proxy/style</a> instead of <a href="http://server1/style" rel="nofollow noreferrer">http://server1/style</a>.  We don't know which server to route this request to since the server1 part of the URL is stripped off.</p>
  
  <p>We have the following location in nginx:</p>
  
  <pre><code>location /foo{
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Host $http_host;
      proxy_set_header X-NginX-Proxy true;
  
      proxy_pass http://server;
      proxy_redirect off;
  }
  </code></pre>
  
  <p>We have two types of legacy servers, one using java servlets and doing most work serverside and one doing a combination of javascript and PHP (did I mention these were old?)</p>
  
  <p>Is there a way to properly redirect these requests, including requests for other resources?</p>