title: Nginx redirect subfolder to another port showing original port
body: <p>How to enable Nginx redirect subfoler to another port using original port? e.g.,</p>
  <p>Service1: <code>http://127.0.0.1:5000</code></p>
  <p>Service2: <code>http://127.0.0.1:8080</code></p>
  <p>Exposed IP port via Nginx is <code>127.0.0.1:6060</code></p>
  <p>The goal is when accessing <code>http://127.0.0.1:6060/sub</code>, it will access <code>http://127.0.0.1:8080</code>, but the URL user see is still <code>http://127.0.0.1:6060/sub</code>.</p>
  <p>I tried two configurations, but they didn't work.</p>
  <pre><code> server {
          listen       6060;
          server_name  127.0.0.1;
  
          location /sub/ {
  
               # method 1: use proxy pass, browser says &quot;static resources not found&quot;
               proxy_set_header X-Real-IP  $remote_addr;
               proxy_set_header X-Forwarded-For $remote_addr;
               proxy_set_header Host $host:6060;
               proxy_pass http://127.0.0.1:8080;
  
               # method 2: use rewrite, the URL will be http://127.0.0.1:8080
               rewrite ^/pct/(.*)$     http://127.0.0.1:8080 redirect;
  
          }
  
          location / {
               proxy_pass http://127.0.0.1:5000;
  
          }
  </code></pre>
  <p>Thanks.</p>