육현진

app2

Showing 1 changed file with 20 additions and 0 deletions
1 +const express = require('express');
2 +const fs = require('fs');
3 +const path = require('path');
4 +const HTTPS = require('https');
5 +const app = express();
6 +const domain = "www.osstest78910.ml"
7 +const sslport = 23023;
8 +try {
9 + const option = {
10 + ca: fs.readFileSync('/etc/letsencrypt/live/' + domain +'/fullchain.pem'),
11 + key: fs.readFileSync(path.resolve(process.cwd(), '/etc/letsencrypt/live/' + domain +'/privkey.pem'), 'utf8').toString(),
12 + cert: fs.readFileSync(path.resolve(process.cwd(), '/etc/letsencrypt/live/' + domain +'/cert.pem'), 'utf8').toString(),
13 + };
14 + HTTPS.createServer(option, app).listen(sslport, () => {
15 + console.log(`[HTTPS] Server is started on port ${sslport}`);
16 + });
17 +} catch (error) {
18 + console.log('[HTTPS] HTTPS 오류가 발생하였습니다. HTTPS 서버는 실행되지 않습니다.');
19 + console.log(error);
20 +}
...\ No newline at end of file ...\ No newline at end of file