title: Nginx to IIS reverse proxy at different path
body: <p>I have a website that is hosted at <a href="http://server/subdir1/subdir2/" rel="nofollow noreferrer">http://server/subdir1/subdir2/</a> that is hosted on an IIS server at <a href="http://dotnet/subdir1/subdir2/website" rel="nofollow noreferrer">http://dotnet/subdir1/subdir2/website</a> where the subdir1/subdir2 portion of each is the same.</p>
  
  <p>I have the following. </p>
  
  <pre><code>location /subdir1/subdir2 {
     rewrite ^/subdir1/subdir2/website(/.*)$ $1 break;
     proxy_pass http://dotnet/subdir1/subdir2/website;
     proxy_set_header Host $host;
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  }
  </code></pre>
  
  <p>When I browse to <a href="http://server/subdir1/subdir2" rel="nofollow noreferrer">http://server/subdir1/subdir2</a> or <a href="http://server/subdir1/subdir2/validpath" rel="nofollow noreferrer">http://server/subdir1/subdir2/validpath</a> it works fine but clicking on any links send me to <a href="http://server/subdir1/subdir2/website/validpath" rel="nofollow noreferrer">http://server/subdir1/subdir2/website/validpath</a> which doesn't work. </p>
  
  <p>What am I missing?</p>