kykint

Add experimental support for HTTPS

Showing 1 changed file with 11 additions and 3 deletions
......@@ -6,7 +6,7 @@
var app = require('../app');
var debug = require('debug')('project:server');
var http = require('http');
var https = require('https');
var fs = require('fs');
/**
......@@ -17,10 +17,18 @@ var port = normalizePort(process.env.PORT || '3000');
app.set('port', port);
/**
* Create HTTP server.
* Create HTTPS server.
*/
var server = http.createServer(app);
const domain = 'kykint.shop';
const certdir = '/etc/letsencrypt/live/' + domain;
const credentials = {
key: fs.readFileSync(certdir + '/privkey.pem', 'utf8'),
cert: fs.readFileSync(certdir + '/cert.pem', 'utf8'),
ca: fs.readFileSync(certdir + '/chain.pem', 'utf8')
}
var server = https.createServer(credentials, app);
/**
* Listen on provided port, on all network interfaces.
......