fix(core): update
This commit is contained in:
@ -40,18 +40,23 @@ export class NginxHost implements IHostConfig {
|
||||
* @param certInstanceArg
|
||||
*/
|
||||
public async deploy() {
|
||||
const filePathConfig = plugins.path.join(paths.nginxHostDirPath, `${this.hostName}.conf`);
|
||||
const filePathPrivate = plugins.path.join(paths.nginxHostDirPath, `${this.hostName}.private.pem`);
|
||||
const filePathPublic = plugins.path.join(paths.nginxHostDirPath, `${this.hostName}.public.pem`);
|
||||
const filePathConfig = plugins.path.join(paths.nginxHostDirPath, `${this.hostName}.conf`);
|
||||
const filePathPrivate = plugins.path.join(
|
||||
paths.nginxHostDirPath,
|
||||
`${this.hostName}.private.pem`
|
||||
);
|
||||
const filePathPublic = plugins.path.join(paths.nginxHostDirPath, `${this.hostName}.public.pem`);
|
||||
|
||||
|
||||
// writeConfig
|
||||
this.configString = snippets.getHostConfigString(this.hostName, this.destination, this.destinationPort);
|
||||
this.configString = snippets.getHostConfigString(
|
||||
this.hostName,
|
||||
this.destination,
|
||||
this.destinationPort
|
||||
);
|
||||
plugins.smartfile.memory.toFsSync(this.configString, filePathConfig);
|
||||
|
||||
// write ssl
|
||||
plugins.smartfile.memory.toFsSync(this.privateKey, filePathPrivate);
|
||||
plugins.smartfile.memory.toFsSync(this.publicKey, filePathPublic);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -115,15 +115,27 @@ export class SmartNginx {
|
||||
|
||||
// write base config
|
||||
plugins.smartfile.fs.ensureDirSync(paths.nginxConfigDirPath);
|
||||
plugins.smartfile.memory.toFsSync(snippets.getBaseConfigString(this.options.defaultProxyUrl), paths.nginxConfFile);
|
||||
plugins.smartfile.memory.toFsSync(
|
||||
snippets.getBaseConfigString(this.options.defaultProxyUrl),
|
||||
paths.nginxConfFile
|
||||
);
|
||||
|
||||
// write standard self signed certificate
|
||||
const selfsignedCert = plugins.selfsigned.generate([{ name: 'commonName', value: 'selfsigned.git.zone' }], { days: 365});
|
||||
|
||||
const selfsignedCert = plugins.selfsigned.generate(
|
||||
[{ name: 'commonName', value: 'selfsigned.git.zone' }],
|
||||
{ days: 365 }
|
||||
);
|
||||
|
||||
// deploy hosts
|
||||
plugins.smartfile.fs.ensureDirSync(paths.nginxHostDirPath);
|
||||
plugins.smartfile.memory.toFsSync(selfsignedCert.private, plugins.path.join(paths.nginxHostDirPath, './default.private.pem'));
|
||||
plugins.smartfile.memory.toFsSync(selfsignedCert.cert, plugins.path.join(paths.nginxHostDirPath, './default.public.pem'));
|
||||
plugins.smartfile.memory.toFsSync(
|
||||
selfsignedCert.private,
|
||||
plugins.path.join(paths.nginxHostDirPath, './default.private.pem')
|
||||
);
|
||||
plugins.smartfile.memory.toFsSync(
|
||||
selfsignedCert.cert,
|
||||
plugins.path.join(paths.nginxHostDirPath, './default.public.pem')
|
||||
);
|
||||
for (const host of this.deployedHosts.getArray()) {
|
||||
await host.deploy();
|
||||
this.logger.log('info', `Host ${host.hostName} deployed!`);
|
||||
|
@ -6,4 +6,4 @@ export const nginxConfigDirPath = plugins.path.join(packageBase, 'nginxconfig');
|
||||
export const nginxHostDirPath = plugins.path.join(nginxConfigDirPath, 'hosts');
|
||||
|
||||
// files
|
||||
export const nginxConfFile = plugins.path.join(nginxConfigDirPath, 'nginx.conf');
|
||||
export const nginxConfFile = plugins.path.join(nginxConfigDirPath, 'nginx.conf');
|
||||
|
@ -17,6 +17,4 @@ export { lik, smartlog, smartpromise, smartshell, smartfile, smartstring, smartu
|
||||
// thirdparty scope
|
||||
import * as selfsigned from 'selfsigned';
|
||||
|
||||
export {
|
||||
selfsigned
|
||||
};
|
||||
export { selfsigned };
|
||||
|
@ -85,8 +85,12 @@ export let getBaseConfigString = (defaultProxy: string) => {
|
||||
return baseConfig;
|
||||
};
|
||||
|
||||
export let getHostConfigString = (hostNameArg: string, destinationIpArg: string, destinationPortArg = 80) => {
|
||||
const hostConfig = plugins.smartstring.indent.normalize(`
|
||||
export let getHostConfigString = (
|
||||
hostNameArg: string,
|
||||
destinationIpArg: string,
|
||||
destinationPortArg = 80
|
||||
) => {
|
||||
const hostConfig = plugins.smartstring.indent.normalize(`
|
||||
upstream ${hostNameArg} {
|
||||
keepalive 100;
|
||||
server ${destinationIpArg}:${destinationPortArg};
|
||||
|
Reference in New Issue
Block a user