title: Binding a Node.js Application on a Port with Nginx
body: <p>I'm trying to set a <em>Node.js Application for Production on a Port with SSL on Nginx Ubuntu 17.04</em>. So far I have <code>SSL Nginx</code> server up and running. </p>
  
  <p>This is how my Nginx Configuration file looks like:</p>
  
  <pre><code>server {
  listen 80 default_server;
  listen [::]:80 default_server;
  listen 443 ssl;
  
  root /var/www/html;
  index index.php index.html index.htm index.nginx-debian.html;
  
  server_name example.com www.example.com;
  
  location / {
      try_files $uri $uri/ =404;
  }
  
  location ~ \.php$ {
      include snippets/fastcgi-php.conf;
      fastcgi_pass unix:/run/php/php7.0-fpm.sock;
  }
  
  location ~ /\.ht {
      deny all;
  }
      ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot
      ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; # managed by Certbot
      include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
  
  if ($scheme != "https") {
      return 301 https://$host$request_uri;
  } 
  
      ssl_dhparam /etc/ssl/certs/dhparam.pem;
  
  }
  </code></pre>
  
  <p>This is how my Node.js Application looks lik:</p>
  
  <pre><code>#content of index.js    
  'use strict';
  
  const http = require('http');
  http.createServer((req, res) =&gt; {
    res.writeHead(200, {
      'Content-Type': 'text/html; charset=utf-8',
    });
    res.write('&lt;h1&gt;I’m a Node app!&lt;/h1&gt;');
    res.end(3000, 'localhost')
  }).listen();
  console.log('http://example.com:3000/');
  </code></pre>
  
  <p>I would want to know how can I bind this Node.js Application on a Port with SSL with the existing Nginx configurations.</p>