Showing
1 changed file
with
28 additions
and
14 deletions
... | @@ -4,26 +4,40 @@ const line = require('@line/bot-sdk'); | ... | @@ -4,26 +4,40 @@ const line = require('@line/bot-sdk'); |
4 | var request = require('request'); | 4 | var request = require('request'); |
5 | var https=require('https'); | 5 | var https=require('https'); |
6 | var http=require('http'); | 6 | var http=require('http'); |
7 | -const lex = require('greenlock-express').create({ | 7 | + |
8 | - version: 'draft-11', | 8 | + |
9 | - configDir: '/etc/letsencrypt/', | 9 | +var fs = require("fs"); |
10 | - email: 'sweun1@naver.com', | 10 | + |
11 | - agreeTos: true, | 11 | +var httpsOptions = { |
12 | - approvedDomains: ['oss.chatbot.bu.to','www.oss.chatbot.bu.to'], | 12 | + key: fs.readFileSync("/etc/letsencrypt/live/oss.chatbot.bu.to/privkey.pem"), |
13 | + cert: fs.readFileSync("/etc/letsencrypt/live/oss.chatbot.bu.to/cert.pem") | ||
14 | +}; | ||
15 | + | ||
16 | +http.createServer(app).listen(80); | ||
17 | +https.createServer(httpsOptions, app).listen(443); | ||
18 | +/* if ssl expired | ||
19 | +var greenlock= require('greenlock-express'); | ||
20 | +const lex = greenlock .create({ | ||
21 | + version: 'draft-11', // 버전2 | ||
22 | + store: require('greenlock-store-fs'), | ||
23 | + configDir: '/etc/letsencrypt', // 또는 ~/letsencrypt/etc | ||
24 | + approveDomains: (opts, certs, cb) => { | ||
25 | + if (certs) { | ||
26 | + opts.domains = ['oss.chatbot.bu.to', 'www.oss.chatbot.bu.to']; | ||
27 | + } else { | ||
28 | + opts.email = 'sweun1@naver.com'; | ||
29 | + opts.agreeTos = true; | ||
30 | + } | ||
31 | + cb(null, { options: opts, certs }); | ||
32 | + | ||
33 | + }, | ||
13 | renewWithin: 81 * 24 * 60 * 60 * 1000, | 34 | renewWithin: 81 * 24 * 60 * 60 * 1000, |
14 | renewBy: 80 * 24 * 60 * 60 * 1000, | 35 | renewBy: 80 * 24 * 60 * 60 * 1000, |
15 | -}).listen(80, 443); | 36 | +});*/ |
16 | - | ||
17 | 37 | ||
18 | //papago api | 38 | //papago api |
19 | 39 | ||
20 | 40 | ||
21 | -https.createServer(lex.httpsOptions, lex.middleware(app)).listen((process.env.SSL_PORT || 443),()=>{ | ||
22 | - console.log("server on 443"); | ||
23 | -}); | ||
24 | -http.createServer(lex.middleware(require('redirect-https')())).listen(process.env.PORT || 80,()=>{ | ||
25 | - console.log("server on 80"); | ||
26 | -}); | ||
27 | //번역 api_url | 41 | //번역 api_url |
28 | var translate_api_url = 'https://openapi.naver.com/v1/papago/n2mt'; | 42 | var translate_api_url = 'https://openapi.naver.com/v1/papago/n2mt'; |
29 | 43 | ... | ... |
-
Please register or login to post a comment