title: Removing Port number from nginx running on non standard port
body: <p>I have an nginx server running on port 9094, and it listens to a server name which is mapped to localhost in the <code>etc/hosts</code> file. </p>
  
  <pre><code>server {
          listen 9094;
          listen [::]:9094;
          server_name www.myserver.local;
          port_in_redirect off;
          server_name_in_redirect off;
  
          proxy_set_header Host $host:$server_port;
  
          location /portal/foreman/ {
                  rewrite ^/portal/foreman(.*)$ $1 break;
                  proxy_pass http://localhost:3001;
                  proxy_set_header Host $host;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          }
  
          location /api/ {
                  rewrite ^/api(.*)$ $1 break;
                  proxy_pass  http://127.0.0.1:8080;
          proxy_set_header Host $host;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          }
  
          location /login {
                  rewrite ^/login(.*)/$ /$1 permanent;
                  proxy_pass http://localhost:3000;
                  proxy_redirect off;
          proxy_set_header Host $host;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          }
  }
  </code></pre>
  
  <p>In my <code>/etc/hosts</code> file i have the following entry</p>
  
  <pre><code>127.0.0.1  www.myserver.local
  </code></pre>
  
  <p>When i enter <code>www.myserver.local:9094</code> everything works as usual, with the redirection. Can someone help me with a way i can remove the port number and the thing still works eg: www.myserver.local/login will redirect me directly to my login page..</p>
  
  <p>when i run www.myserver.local in my browser, the browser gives an error saying, refused to connect</p>