장주현

ssl

Showing 1 changed file with 17 additions and 0 deletions
...@@ -6,6 +6,8 @@ const app = express(); ...@@ -6,6 +6,8 @@ const app = express();
6 const PAPAGO_URL = 'https://openapi.naver.com/v1/papago/n2mt' 6 const PAPAGO_URL = 'https://openapi.naver.com/v1/papago/n2mt'
7 const PAPAGO_ID = 'cIZBOTfISMHEyygh_NHp'; 7 const PAPAGO_ID = 'cIZBOTfISMHEyygh_NHp';
8 const PAPAGO_SECRET = '8D32UNGgYp'; 8 const PAPAGO_SECRET = '8D32UNGgYp';
9 +const HTTPS = require('https');
10 +const domain = "www.chatosscjh.tk"
9 const PORT = process.env.PORT || 3000; 11 const PORT = process.env.PORT || 3000;
10 12
11 //const indexRoute = require("./routes/index"); 13 //const indexRoute = require("./routes/index");
...@@ -123,3 +125,18 @@ function trans(message, totrans){ ...@@ -123,3 +125,18 @@ function trans(message, totrans){
123 } 125 }
124 }); 126 });
125 }; 127 };
128 +
129 +try {
130 + const option = {
131 + ca: fs.readFileSync('/etc/letsencrypt/live/' + domain +'/fullchain.pem'),
132 + key: fs.readFileSync(path.resolve(process.cwd(), '/etc/letsencrypt/live/'$
133 + cert: fs.readFileSync(path.resolve(process.cwd(), '/etc/letsencrypt/live/$
134 + };
135 +
136 + HTTPS.createServer(option, app).listen(sslport, () => {
137 + console.log(`[HTTPS] Server is started on port ${sslport}`);
138 + });
139 + } catch (error) {
140 + console.log('[HTTPS] HTTPS 오류가 발생하였습니다. HTTPS 서버는 실행되지 $
141 + console.log(error);
142 + }
......