Seongwook Jin

ssl added

1 +const express = require('express');
2 +const fs = require('fs');
3 +const path = require('path');
4 +const HTTPS = require('https');
5 +
6 +const app = express();
7 +const domain = "www.stagefive.tk"
8 +const sslport = 23023;
9 +
10 +
11 +try {
12 + const option = {
13 + ca: fs.readFileSync('/etc/letsencrypt/live/' + domain +'/fullchain.pem'),
14 + key: fs.readFileSync(path.resolve(process.cwd(), '/etc/letsencrypt/live/' + domain +'/privkey.pem'), 'utf8').toString(),
15 + cert: fs.readFileSync(path.resolve(process.cwd(), '/etc/letsencrypt/live/' + domain +'/cert.pem'), 'utf8').toString(),
16 + };
17 +
18 + HTTPS.createServer(option, app).listen(sslport, () => {
19 + console.log(`[HTTPS] Server is started on port ${sslport}`);
20 + });
21 +} catch (error) {
22 + console.log('[HTTPS] HTTPS 오류가 발생하였습니다. HTTPS 서버는 실행되지 않습니다.');
23 + console.log(error);
24 +}
25 +
This diff is collapsed. Click to expand it.
1 +{
2 + "name": "ssl",
3 + "version": "1.0.0",
4 + "description": "",
5 + "main": "app.js",
6 + "scripts": {
7 + "test": "echo \"Error: no test specified\" && exit 1"
8 + },
9 + "author": "",
10 + "license": "ISC",
11 + "dependencies": {
12 + "express": "^4.17.1"
13 + }
14 +}