title: nginx proxy_pass is setting port in response
body: <p>I have an Nginx config similar to:</p>
  
  <pre><code>server {
      listen 80;
      listen 443;
      server_name api.mysite.dev;
  
      location / {
  
          proxy_set_header Host "api.mysite.dev";
          proxy_set_header X-Real-IP $remote_addr;
          proxy_pass  $scheme://127.0.0.1:8001;
      }
  
  }
  
  server {
      listen 80;
      listen 443;
      server_name mysite.dev www.mysite.dev;
  
      # Forward all /api/ requests ti api.mysite.dev
      # sadly need to keep this around for backwards compatibility
      location /api/ {
          proxy_set_header Host "api.mysite.dev";
          proxy_set_header X-Real-IP $remote_addr;
          proxy_pass $scheme://127.0.0.1:8001/;
  
      }
      # The proxy_pass here ends up putting the port (8002) in the response URL.
      location / {
          proxy_set_header Host "www.mysite.dev";
          proxy_set_header X-Real-IP $remote_addr;
          proxy_pass  $scheme://127.0.0.1:8002;
      }
  }
  </code></pre>
  
  <p>So, as said in the comment, when I request www.mysite.dev, my browser is forwarded to www.mysite.dev:8002.
  Any ideas what I'm doing wrong here?</p>
  
  <p>Thanks in advance!</p>