title: NGINX proxy_pass remove path prefix & resolve DNS
body: <p>I'd like to proxy a request to another server using proxy_pass while removing the matched path prefix. I believe that one way of doing this is as follows;</p>
  
  <pre><code>location /a/ {
    proxy_pass https://website.com/
  }
  </code></pre>
  
  <p>E.g. a request to <code>http://localhost/a/b.html</code> would be proxied to <code>https://website.com/b.html</code>.</p>
  
  <p>As far as I am aware the issue with this in non-commercial versions on NGINX is that the DNS A record for <code>website.com</code> would be loaded and cached forever on startup. I've seen a technique to workaround this by using a variable such as <code>$request_uri</code> in the proxy_pass directive, thus forcing NGINX to re-resolve the DNS according to the TTL of the record.</p>
  
  <p>E.g.</p>
  
  <pre><code>location /a/ {
    rewrite ^/a/(.*) /$1  break;
    proxy_pass https://website.com/$request_uri
  }
  </code></pre>
  
  <p>Unfortunately, it seems that the above doesn't work as it seems to still pass the /a/ prefix to the upstream.</p>
  
  <p>Essentially all I want to achieve here is to proxy a request while removing the path prefix in such a way that DNS records are not cached forever. </p>
  
  <p>Thanks.</p>