Showing
1 changed file
with
23 additions
and
0 deletions
1 | +const fs = require('fs'); | ||
2 | +const path = require('path'); | ||
3 | +const HTTPS = require('https'); | ||
4 | +const domain = "2019110627.osschatbot.ga"; | ||
5 | +const sslport = 23023; | ||
6 | + | ||
1 | var express = require('express'); | 7 | var express = require('express'); |
2 | var app=express(); | 8 | var app=express(); |
3 | var test=require('./test.js'); | 9 | var test=require('./test.js'); |
... | @@ -29,6 +35,23 @@ app.get("/",(req,res)=>{ | ... | @@ -29,6 +35,23 @@ app.get("/",(req,res)=>{ |
29 | }); | 35 | }); |
30 | 36 | ||
31 | /* server */ | 37 | /* server */ |
38 | +try { | ||
39 | + const option = { | ||
40 | + ca: fs.readFileSync('/etc/letsencrypt/live/' + domain +'/fullchain.pem'), | ||
41 | + key: fs.readFileSync(path.resolve(process.cwd(), '/etc/letsencrypt/live/' + domain +'/privkey.pem'), 'utf8').toString(), | ||
42 | + cert: fs.readFileSync(path.resolve(process.cwd(), '/etc/letsencrypt/live/' + domain +'/cert.pem'), 'utf8').toString(), | ||
43 | + }; | ||
44 | + | ||
45 | + HTTPS.createServer(option, app).listen(sslport, () => { | ||
46 | + console.log(`[HTTPS] Server is started on port ${sslport}`); | ||
47 | + }); | ||
48 | + } catch (error) { | ||
49 | + console.log('[HTTPS] HTTPS 오류가 발생하였습니다. HTTPS 서버는 실행되지 않습니다.'); | ||
50 | + console.log(error); | ||
51 | + } | ||
52 | + | ||
53 | +/* local server | ||
32 | app.listen("8080",function(req,res){ | 54 | app.listen("8080",function(req,res){ |
33 | console.log('server listening at port no. 8080'); | 55 | console.log('server listening at port no. 8080'); |
34 | }); | 56 | }); |
57 | +*/ | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or login to post a comment