title: How to hide port in nginx reverse proxy pass
body: <p>I've got 2 Blazor applications (more incoming) that I want to reach from the 80 port.</p>
  <p>Let's say that my reverse proxy server ip is 1.2.3.4, I want to reach my first service from <a href="http://1.2.3.4/example1" rel="nofollow noreferrer">http://1.2.3.4/example1</a>. But with my current configuration, I've got to type <a href="http://1.2.3.4:5000/example1" rel="nofollow noreferrer">http://1.2.3.4:5000/example1</a> to reach it.</p>
  <p>What I've tried (not exhaustive) :</p>
  <ul>
  <li>server_name_in_redirect off;</li>
  <li>proxy_set_header Host $host:$server_port;</li>
  <li>proxy_set_header X-Forwarded-For $remote_addr;</li>
  </ul>
  <p>I've also removed my backup servers from my configuration and called proxy_pass directly (proxy_pass 1.1.1.1:5000).
  I've also tried proxy_redirect after proxy_pass.</p>
  <p>I've read all topics around that question on Stackoverflow/ServerFault but nothing worked.
  I guess there is something I don't understand so I need your help.</p>
  <p>2 questions :</p>
  <ul>
  <li>How can I achieve what I want to do?</li>
  <li>Why do I have this behavior? If my backup server had a different port, how could it work?</li>
  </ul>
  <h1></h1>
  <pre><code>upstream example1 {
      server 1.1.1.1:5000;
      server 1.1.1.2:5000 backup;
  }
  upstream example2 {
      server 1.1.1.1:5002;
      server 1.1.1.2:5002 backup;
  }
  
  server {
      server_name  _;
      root         /usr/share/nginx/html;
      listen      80 default_server;
      proxy_read_timeout 3600;
  
      # Load configuration files for the default server block.
      include /etc/nginx/default.d/*.conf;
  
      location /card {
          proxy_pass http://example1;
  
      }
      location /user {
          proxy_pass http://example2;
      }
  }
  </code></pre>
  <p>Thank you!</p>