title: nodejs app accessible on port 3000 behind nginx reverse proxy
body: <p>I am running a nodejs application with nodejs app an server listening on port 3000. I use nginx as a reverse proxy which also handles ssl. the configuration is listed below (and it seems to me after reading several tutorials and forum posts it is pretty standard). Everything works as expected except from the fact that i am still able to accesss the app under "<a href="http://example.com:3000" rel="noreferrer">http://example.com:3000</a>". Does that mean i need to add another server listening on port 3000 for redirects to https? This could either mean that the tutorials i read so far are somewhat incomplete or I am overlooking something fundamental. Can anyone help me figure out what it is?</p>
  
  <pre><code> # app server upstream
  
  upstream app {
      server 127.0.0.1:3000;
  }
  
  # default http server. Redirect to https server
  
  server {
      listen 80;
      server_name www.example.com example.com;
      return 301 https://example.com$request_uri;  
  }
  
  # https server
  
  server {
      listen 443;
      server_name www.example.com example.com;
  
      ssl on;
      ssl_certificate ssl.crt;
      ssl_certificate_key ssl.key;
  
      ssl_session_timeout 5m;
  
      ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
      ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES";
      ssl_prefer_server_ciphers on;
  
      location / {
          proxy_pass http://app;
          proxy_http_version 1.1;
          proxy_set_header Upgrade $http_upgrade;
          proxy_set_header Connection 'upgrade';
          proxy_set_header Host $host;
          proxy_cache_bypass $http_upgrade;   
      }
  }   
  </code></pre>