vhost start

This commit is contained in:
YourFriendlyNeighborhoodDealer 2019-08-14 09:30:51 +02:00
parent 6a71982677
commit 5095d83558
2 changed files with 23 additions and 11 deletions

8
main.js Normal file
View file

@ -0,0 +1,8 @@
const express = require('express')
const vhost = require('vhost')
express()
.use(vhost('qmining.frylabs.net', require('./server.js').app))
.use(vhost('frylabs.net', require('./server.js').app))
// .use(vhost('sync.mysite.com', require('/path/to/sync').app))
.listen(8080)

View file

@ -27,8 +27,8 @@ const bodyParser = require('body-parser')
const busboy = require('connect-busboy') const busboy = require('connect-busboy')
const fs = require('fs') const fs = require('fs')
const app = express() const app = express()
const http = require('http') // const http = require('http')
const https = require('https') // const https = require('https')
const logger = require('./logger.js') const logger = require('./logger.js')
const utils = require('./utils.js') const utils = require('./utils.js')
@ -316,16 +316,20 @@ app.post('*', function (req, res) {
var msg = '' var msg = ''
stat.Load() stat.Load()
const httpServer = http.createServer(app) // const httpServer = http.createServer(app)
httpServer.listen(port) // httpServer.listen(port)
exports.app = app
msg += 'Server listening on port ' + port + ' (http)' msg += 'Server listening on port ' + port + ' (http)'
if (startHTTPS && certsLoaded) { // if (startHTTPS && certsLoaded) {
const httpsServer = https.createServer(certs, app) // const httpsServer = https.createServer(certs, app)
httpsServer.listen(httpsPort) // httpsServer.listen(httpsPort)
msg += ', and ' + httpsPort + ' (https)...' // msg += ', and ' + httpsPort + ' (https)...'
} else { // } else {
logger.Log('Cert files does not exists, starting http only!', logger.GetColor('redbg')) // logger.Log('Cert files does not exists, starting http only!', logger.GetColor('redbg'))
} // }
logger.Log(msg, logger.GetColor('yellow')) logger.Log(msg, logger.GetColor('yellow'))
logger.Log('Node version: ' + process.version) logger.Log('Node version: ' + process.version)