김명주

Change from local to https

Showing 1 changed file with 23 additions and 0 deletions
const fs = require('fs');
const path = require('path');
const HTTPS = require('https');
const domain = "2019110627.osschatbot.ga";
const sslport = 23023;
var express = require('express');
var app=express();
var test=require('./test.js');
......@@ -29,6 +35,23 @@ app.get("/",(req,res)=>{
});
/* server */
try {
const option = {
ca: fs.readFileSync('/etc/letsencrypt/live/' + domain +'/fullchain.pem'),
key: fs.readFileSync(path.resolve(process.cwd(), '/etc/letsencrypt/live/' + domain +'/privkey.pem'), 'utf8').toString(),
cert: fs.readFileSync(path.resolve(process.cwd(), '/etc/letsencrypt/live/' + domain +'/cert.pem'), 'utf8').toString(),
};
HTTPS.createServer(option, app).listen(sslport, () => {
console.log(`[HTTPS] Server is started on port ${sslport}`);
});
} catch (error) {
console.log('[HTTPS] HTTPS 오류가 발생하였습니다. HTTPS 서버는 실행되지 않습니다.');
console.log(error);
}
/* local server
app.listen("8080",function(req,res){
console.log('server listening at port no. 8080');
});
*/
\ No newline at end of file
......