title: Enabling HTTPS on NGINX for a node js application is not working
body: <p>I am using a simple &quot;hello world&quot; Express.JS (8080 port) application deployed in Ubuntu Server, with NGINX reverse proxy setup as below.</p>
  <p>The application working well for http port but not for https port</p>
  <ul>
  <li>nginx version: nginx/1.10.3 (Ubuntu)</li>
  <li>OpenSSL 1.0.2g  1 Mar 2016</li>
  </ul>
  <p>And my configuration file is like this:</p>
  <pre><code>server {
          listen 80;
          listen 443 default ssl;
          server_name localhost;
  
           ssl_certificate /root/mydir/ssl/certificate.crt;
           ssl_certificate_key /root/mydir/ssl/private.key;
  
      location / {
                  proxy_pass http://localhost:8080;
                  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>
  <p>The configuration is working fine for http connection for my domain testdomain.com, but completely failing for <a href="https://testdomain.com" rel="nofollow noreferrer">https://testdomain.com</a> or <a href="https://www.testdomain.com" rel="nofollow noreferrer">https://www.testdomain.com</a></p>
  <p>What went wrong with this configuration?</p>
  <p>SSL certs are generated by sslforfree.com.</p>