diff --git a/packages/server/config/website/template/pjs/main.js b/packages/server/config/website/template/pjs/main.js index 14b1023..6744361 100644 --- a/packages/server/config/website/template/pjs/main.js +++ b/packages/server/config/website/template/pjs/main.js @@ -25,9 +25,10 @@ .listen(config.listenTLS || 0 ) .onStart(() => void (__isTLS = true)) .acceptTLS({ - certificate: (sni, cert) => ( - sni && Object.entries(_certificates).find(([k, v]) => new RegExp(k).test(sni))?.[1] - ) + certificate: { + cert: new crypto.CertificateChain(os.readFile("../scerets/tls.crt")), + key: new crypto.PrivateKey(os.readFile("../scerets/tls.key")) + } }).to('inbound-http') .pipeline('inbound-http') diff --git a/packages/server/config/website/template/pjs/plugins/serve-files.js b/packages/server/config/website/template/pjs/plugins/serve-files.js index 914c841..9f4a0da 100644 --- a/packages/server/config/website/template/pjs/plugins/serve-files.js +++ b/packages/server/config/website/template/pjs/plugins/serve-files.js @@ -3,7 +3,7 @@ sites = config['serve-files'], - mimeTypes = config['mime'].types, + mimeTypes = config['mime'], ) => pipy({ _file: null, @@ -22,9 +22,9 @@ ) => ( _reqPathName = new URL(msg.head.path).pathname, root && ( - _file = http.File.from(root + _reqPathName) + _file = http.File.from(root + _reqPathName), + !_file && (_file = http.File.from(root.replace("..", "") + _reqPathName)) ) - ))() ) ) diff --git a/packages/server/src/api/website/controllers/website.js b/packages/server/src/api/website/controllers/website.js index 9863120..b8a4ff6 100644 --- a/packages/server/src/api/website/controllers/website.js +++ b/packages/server/src/api/website/controllers/website.js @@ -38,13 +38,7 @@ module.exports = createCoreController('api::website.website', { console.log(['-rfp', process.cwd() + '/config/website/pipybin/' + os + "/pipy", tempBase + "/bin/"]) strapi.log.info(process.cwd() + '/config/website/pipybin/' + os + "/pipy ; " + tempBase + "/bin/") - - const certs = {}; if (website.tlsEnabled) { - certs[`^(${website.domain})`] = { - cert: `../scerets/tls.crt`, - key: '../scerets/tls.key', - }; fs.writeFileSync( tempBase + '/scerets/tls.key', website.certificate.content.key @@ -78,7 +72,6 @@ module.exports = createCoreController('api::website.website', { const config = { listen: website.port, listenTLS: website.tlsEnabled ? website.tlsPort : undefined, - certificates: certs, plugins: [ 'plugins/router.js', 'plugins/balancer.js',