title: Listen on HTTP and HTTPS for a single express app
body: <p>Can I create an Express server listening on both HTTP and HTTPS, with the same routes and the same middlewares?</p>
  
  <p>Currently I do this with Express on HTTP, with <a href="http://www.stunnel.org/">stunnel</a> tunneling HTTPS to Express, but I prefer a pure Node solution.</p>
  
  <p>I can do it with this code, but using the <code>handle</code> method that is marked as private:</p>
  
  <pre><code>var express = require( 'express' )
      , https = require("https")
      , fs = require( 'fs' );
  
  var app = express.createServer();
  // init routes and middlewares
  app.listen( 80 );
  
  var privateKey = fs.readFileSync( 'privatekey.pem' ).toString();
  var certificate = fs.readFileSync( 'certificate.pem' ).toString();
  var options = {key: privateKey, cert: certificate};
  https.createServer( options, function(req,res)
  {
      app.handle( req, res );
  } ).listen( 443 );
  </code></pre>