From 8f47119c6bc549150b8f88a6c8b6b22c242c0909 Mon Sep 17 00:00:00 2001 From: lulu Date: Mon, 22 Oct 2018 17:21:33 +0800 Subject: [PATCH] =?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=8F=AA=E5=90=AF=E5=8A=A8?= =?UTF-8?q?=20http=20server=EF=BC=8C=E4=B8=8D=E8=A6=81=20https=20server?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ConfigSys.js | 2 +- server.js | 16 ++++++---------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/ConfigSys.js b/ConfigSys.js index dcb89c0..1d9a922 100644 --- a/ConfigSys.js +++ b/ConfigSys.js @@ -1,5 +1,5 @@ module.exports={ - protocol:'httpall', + protocol:'http', host:'localhost', port:undefined, // 如果使用 https 协议,必须填写以下内容,或在命令行参数中设置: diff --git a/server.js b/server.js index 8025a6e..f93cd05 100644 --- a/server.js +++ b/server.js @@ -28,7 +28,7 @@ try { // 载入命令行参数 commander .version(Config.VERSION, '-v, --version') // 默认是 -V。如果要 -v,就要加 '-v --version' - .option('-h, --host ', 'host ip or domain name') + .option('-H, --host ', 'host ip or domain name') .option('-P, --protocol ', 'Web server protocol http|https|httpall, default to httpall') .option('-p, --port ', 'Server port, default to 80|443') .option('--sslCert ', 'SSL cert file') @@ -37,8 +37,8 @@ try { .parse(process.argv) // 把命令行参数 合并入配置。 - Config.host=commander.host || Config.host || 'localhost' - Config.protocol=commander.protocol || Config.protocol || 'httpall' // 默认同时启用 http 和 https + Config.host=commander.host || Config.host + Config.protocol=commander.protocol || Config.protocol // 默认同时启用 http 和 https Config.port=parseInt(commander.port) || parseInt(Config.port) || (Config.protocol==='http'?80:Config.protocol==='https'?443:undefined) // 端口默认为 http:80, https:443, httpall: 80|443 Config.sslCert=commander.sslCert || Config.sslCert Config.sslKey=commander.sslKey || Config.sslKey @@ -76,16 +76,12 @@ async function init(){ /*** 设置全局对象 ***/ server.use(compression()) /*** 路由 ***/ - //server.use(express.static(path.join(__dirname,'dist'), {index:'index.html'})) + server.use(express.static(path.join(__dirname,'dist'), {index:'index.html'})) - var webroot=express.static(path.join(__dirname,'dist'), {index:'index.html'}) - server.use(webroot) - - // var vhost = require('vhost') +// var vhost = require('vhost') +// var webroot=express.static(path.join(__dirname,'dist'), {index:'index.html'}) // server.use(vhost('bittic.org', webroot)) // server.use(vhost('www.bittic.org', webroot)) - // server.use(vhost('box.bittic.org', express.static(path.join(__dirname,'../ticbox/dist'), {index:'index.html'}))) - // server.use(vhost('wallet.bittic.org', express.static(path.join(__dirname,'../ticwalletx/dist'), {index:'index.html'}))) // server.use(vhost('*', webroot)) // server.use(vhost('*.*', webroot)) // server.use(vhost('*.*.*', webroot))