kykint

Add experimental support for HTTPS

Showing 1 changed file with 11 additions and 3 deletions
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
6 6
7 var app = require('../app'); 7 var app = require('../app');
8 var debug = require('debug')('project:server'); 8 var debug = require('debug')('project:server');
9 -var http = require('http'); 9 +var https = require('https');
10 var fs = require('fs'); 10 var fs = require('fs');
11 11
12 /** 12 /**
...@@ -17,10 +17,18 @@ var port = normalizePort(process.env.PORT || '3000'); ...@@ -17,10 +17,18 @@ var port = normalizePort(process.env.PORT || '3000');
17 app.set('port', port); 17 app.set('port', port);
18 18
19 /** 19 /**
20 - * Create HTTP server. 20 + * Create HTTPS server.
21 */ 21 */
22 22
23 -var server = http.createServer(app); 23 +const domain = 'kykint.shop';
24 +const certdir = '/etc/letsencrypt/live/' + domain;
25 +const credentials = {
26 + key: fs.readFileSync(certdir + '/privkey.pem', 'utf8'),
27 + cert: fs.readFileSync(certdir + '/cert.pem', 'utf8'),
28 + ca: fs.readFileSync(certdir + '/chain.pem', 'utf8')
29 +}
30 +
31 +var server = https.createServer(credentials, app);
24 32
25 /** 33 /**
26 * Listen on provided port, on all network interfaces. 34 * Listen on provided port, on all network interfaces.
......