diff --git a/bin/start/serve.js b/bin/start/serve.js index 94946d6..4b436ab 100644 --- a/bin/start/serve.js +++ b/bin/start/serve.js @@ -65,6 +65,7 @@ async function listenHttp() { await redirect.listen(config.httpPort, config.address) console.log('HTTP Redirecting to HTTPS on', config.httpPort) // eslint-disable-line } else if (config.secure && config.ssl.mode === 'manual') { + router.route(Acme.route(isMainThread ? {} : { get: getFromParent })) await router.listen(config.httpPort, config.address) console.log('HTTP (manual ssl) listening on', config.httpPort) // eslint-disable-line } else { @@ -119,6 +120,7 @@ async function listenHttps() { isMainThread && config.acme.domains.length && await runAcme() sslListener && (sslListener.unlisten(), sslListener = null) sslListener = await router.listen(config.httpsPort, config.address, config.ssl) + server.configureSsl && await server.configureSsl(router) console.log('HTTPS Listening on', config.httpsPort) // eslint-disable-line } diff --git a/shared/server/index.js b/shared/server/index.js index 03c0623..4b057d4 100644 --- a/shared/server/index.js +++ b/shared/server/index.js @@ -12,7 +12,6 @@ export default function Server({ ...o } = {}) { let uws - , isSsl , handle , wrapper @@ -43,7 +42,6 @@ export default function Server({ return router function addServerName(name, options) { - if (!isSsl) return uws.addServerName(name, options) uws.domain(name).any('/*', wrapper) } @@ -127,8 +125,7 @@ export default function Server({ port = parseInt(port) wrapper = wrap - isSsl = !!(o.cert || o.mode === 'manual') - uws = isSsl + uws = !!(o.cert || o.mode === 'manual') ? uWS.SSLApp({ cert_file_name: o.cert, key_file_name: o.key, ...o }) : uWS.App(o) asn.forEach(xs => addServerName(...xs))