Ubuntu

added https

...@@ -7,6 +7,32 @@ ...@@ -7,6 +7,32 @@
7 var app = require("../app"); 7 var app = require("../app");
8 var debug = require("debug")("screensaver:server"); 8 var debug = require("debug")("screensaver:server");
9 var http = require("http"); 9 var http = require("http");
10 +const fs = require('fs');
11 +const path = require('path');
12 +const HTTPS = require('https');
13 +const domain = "www.madcat.ga"
14 +const sslport = 23023;
15 +
16 +
17 +
18 +try {
19 + const option = {
20 + ca: fs.readFileSync('/etc/letsencrypt/live/' + domain +'/fullchain.pem'),
21 + key: fs.readFileSync(path.resolve(process.cwd(), '/etc/letsencrypt/live/' + domain +'/privkey.pem'), 'utf8').toString(),
22 + cert: fs.readFileSync(path.resolve(process.cwd(), '/etc/letsencrypt/live/' + domain +'/cert.pem'), 'utf8').toString(),
23 + };
24 +
25 + HTTPS.createServer(option, app).listen(sslport, () => {
26 + console.log(`[HTTPS] Server is started on port ${sslport}`);
27 + });
28 +} catch (error) {
29 + console.log('[HTTPS] HTTPS 오류가 발생하였습니다. HTTPS 서버는 실행되지 않습니다.');
30 + console.log(error);
31 +}
32 +
33 +
34 +
35 +
10 36
11 /** 37 /**
12 * Get port from environment and store in Express. 38 * Get port from environment and store in Express.
......