Compare commits

...

66 Commits

Author SHA1 Message Date
e3817f92c7 2.0.47 2019-04-11 02:01:45 +02:00
159c043ba6 fix(core): update 2019-04-11 02:01:44 +02:00
fbdb98c355 2.0.46 2019-04-11 01:42:49 +02:00
b81dc319e2 fix(core): update 2019-04-11 01:42:48 +02:00
eec249d68f 2.0.45 2019-04-11 01:32:08 +02:00
0f4a5b0cc1 fix(core): update 2019-04-11 01:32:08 +02:00
20c23751a4 2.0.44 2019-04-11 00:40:34 +02:00
6aaae7683b fix(core): update 2019-04-11 00:40:33 +02:00
826ae9f157 2.0.43 2019-04-11 00:15:06 +02:00
9dbeef0ed2 fix(core): update 2019-04-11 00:15:06 +02:00
53f6daa5d5 2.0.42 2019-04-10 23:15:37 +02:00
9ee5cd2a3d fix(core): update 2019-04-10 23:15:37 +02:00
13c27bb71e 2.0.41 2019-04-10 23:14:08 +02:00
2be54dd505 fix(core): update 2019-04-10 23:14:08 +02:00
2c5af1840e 2.0.40 2019-04-10 19:03:17 +02:00
e5b75014af fix(core): update 2019-04-10 19:03:17 +02:00
82f3b4bd7d 2.0.39 2019-02-02 12:10:00 +01:00
4186e77ca0 fix(core): cleanup 2019-02-02 12:09:59 +01:00
6a05c0087f 2.0.38 2019-01-25 12:37:13 +01:00
4206c9bc8a fix(core): update 2019-01-25 12:37:12 +01:00
0aa6966dc1 2.0.37 2019-01-22 22:42:54 +01:00
5bbd773460 fix(core): update 2019-01-22 22:42:54 +01:00
2c81f8b492 2.0.36 2019-01-22 22:07:59 +01:00
0fe7d586cf fix(core): update 2019-01-22 22:07:58 +01:00
a4c8b789ad 2.0.35 2019-01-22 22:05:03 +01:00
b4378e305a fix(core): update 2019-01-22 22:05:02 +01:00
5ff0980908 2.0.34 2019-01-22 18:59:56 +01:00
e60257d761 fix(core): update 2019-01-22 18:59:55 +01:00
e94f0edafb 2.0.33 2019-01-22 18:25:44 +01:00
c417d96e48 fix(core): update 2019-01-22 18:25:43 +01:00
c5b1dbb46e 2.0.32 2019-01-22 12:33:48 +01:00
893a2e2709 fix(core): update 2019-01-22 12:33:47 +01:00
01f0dc6b20 2.0.31 2019-01-22 12:11:32 +01:00
736a42066c fix(core): update 2019-01-22 12:11:31 +01:00
44403863d1 2.0.30 2019-01-22 12:03:00 +01:00
5be21fa100 fix(core): update 2019-01-22 12:02:59 +01:00
042167c01e 2.0.29 2019-01-22 04:03:17 +01:00
db38d038ef fix(core): update 2019-01-22 04:03:17 +01:00
a4d8a46360 2.0.28 2019-01-19 15:57:50 +01:00
84e5c10129 fix(core): update 2019-01-19 15:57:49 +01:00
98a2871f08 2.0.27 2019-01-19 15:42:46 +01:00
9bb847210a fix(core): update 2019-01-19 15:42:45 +01:00
91d4ba5715 2.0.26 2019-01-19 15:41:51 +01:00
3ee2988964 fix(core): update 2019-01-19 15:41:51 +01:00
221f1f6237 2.0.25 2019-01-19 12:17:47 +01:00
0a6fbf588e fix(core): update 2019-01-19 12:17:47 +01:00
1a8546af6e 2.0.24 2019-01-19 11:07:14 +01:00
9e01bdb8e2 fix(core): update 2019-01-19 11:07:14 +01:00
33833fbc6c 2.0.23 2019-01-19 10:59:25 +01:00
97b5678fe4 fix(core): update 2019-01-19 10:59:24 +01:00
9b96984413 2.0.22 2019-01-19 03:21:27 +01:00
0de412b842 fix(core): update 2019-01-19 03:21:27 +01:00
64bcce9e23 2.0.21 2019-01-19 03:04:38 +01:00
390812ec33 fix(core): update 2019-01-19 03:04:38 +01:00
a672bb920f 2.0.20 2019-01-19 02:46:41 +01:00
c3fabb6107 fix(core): update 2019-01-19 02:46:41 +01:00
b4ebdbae47 2.0.19 2019-01-19 02:44:52 +01:00
c55d2dcf10 fix(core): update 2019-01-19 02:44:52 +01:00
7274d5ea8a 2.0.18 2019-01-19 02:25:35 +01:00
1ec733c2a9 fix(core): update 2019-01-19 02:25:34 +01:00
3ef14d8ac7 2.0.17 2019-01-18 01:33:02 +01:00
f332bf95fe fix(core): update 2019-01-18 01:33:01 +01:00
6acad8a306 2.0.16 2019-01-18 00:46:09 +01:00
6ae672f707 fix(core): update 2019-01-18 00:46:08 +01:00
3d263e2181 2.0.15 2019-01-18 00:45:29 +01:00
85639f29af fix(core): update 2019-01-18 00:45:29 +01:00
23 changed files with 254 additions and 500 deletions

3
dist/index.d.ts vendored
View File

@ -1,3 +0,0 @@
export * from "./smartnginx.classes.nginxconfig";
export * from "./smartnginx.classes.nginxprocess";
export * from "./smartnginx.classes.nginxhost";

9
dist/index.js vendored
View File

@ -1,9 +0,0 @@
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
// classes
__export(require("./smartnginx.classes.nginxconfig"));
__export(require("./smartnginx.classes.nginxprocess"));
__export(require("./smartnginx.classes.nginxhost"));
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7O0FBRUEsVUFBVTtBQUNWLGlCQUFjLGtDQUFrQyxDQUFDLEVBQUE7QUFDakQsaUJBQWMsbUNBQW1DLENBQUMsRUFBQTtBQUNsRCxpQkFBYyxnQ0FBZ0MsQ0FBQyxFQUFBIn0=

View File

@ -1,19 +0,0 @@
/// <reference types="q" />
import * as plugins from "./smartnginx.plugins";
import { NginxHost } from "./smartnginx.classes.nginxhost";
import { NginxProcess } from "./smartnginx.classes.nginxprocess";
/**
* main class that manages a NginxInstance
*/
export declare class NginxConfig {
hosts: NginxHost[];
cert: plugins.cert.Cert;
nginxProcess: NginxProcess;
isDeployed: boolean;
constructor(optionsArg: plugins.cert.ICertConstructorOptions);
addHost(nginxHostArg: NginxHost): void;
listHosts(): NginxHost[];
removeHost(nginxHostArg: NginxHost): void;
clean(): void;
deploy(): plugins.q.Promise<{}>;
}

View File

@ -1,71 +0,0 @@
"use strict";
const plugins = require("./smartnginx.plugins");
const paths = require("./smartnginx.paths");
const snippets = require("./smartnginx.snippets");
const smartnginx_classes_nginxprocess_1 = require("./smartnginx.classes.nginxprocess");
let allConfigs = [];
/**
* main class that manages a NginxInstance
*/
class NginxConfig {
constructor(optionsArg) {
this.hosts = [];
this.nginxProcess = new smartnginx_classes_nginxprocess_1.NginxProcess(this);
this.isDeployed = false;
this.cert = new plugins.cert.Cert({
cfEmail: optionsArg.cfEmail,
cfKey: optionsArg.cfKey,
sslDir: paths.nginxCertBase,
gitOriginRepo: optionsArg.gitOriginRepo,
testMode: optionsArg.testMode
});
}
;
// interact with Hosts
addHost(nginxHostArg) {
this.hosts.push(nginxHostArg);
}
listHosts() {
return this.hosts;
}
;
removeHost(nginxHostArg) {
}
clean() {
this.hosts = [];
}
// handle deployment of hosts
deploy() {
let done = plugins.q.defer();
plugins.smartfile.fs.ensureDirSync(paths.nginxConfigBase);
plugins.smartfile.fs.ensureDirSync(paths.nginxHostFileBase);
plugins.smartfile.fs.ensureDirSync(paths.nginxCertBase);
for (let config of allConfigs) {
config.isDeployed = false;
}
;
this.isDeployed = true;
// write base config
plugins.smartfile.memory.toFsSync(snippets.getBaseConfigString(), paths.nginxConfFile);
// deploy hosts
let promiseArray = [];
for (let host of this.hosts) {
let hostDeployedPromise = host.deploy(this.cert);
hostDeployedPromise.then(() => {
plugins.beautylog.info(`Host ${host.hostName} deployed!`);
this.nginxProcess.reloadConfig();
});
promiseArray.push(hostDeployedPromise);
}
;
plugins.q.all(promiseArray)
.then(() => {
done.resolve();
});
return done.promise;
}
;
}
exports.NginxConfig = NginxConfig;
;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRuZ2lueC5jbGFzc2VzLm5naW54Y29uZmlnLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRuZ2lueC5jbGFzc2VzLm5naW54Y29uZmlnLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxNQUFZLE9BQ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sSUFBSSxDQUFDLFFBQVEsSUFBSSxDQUFDLFFBQVEsWUFBWSxDQUFDLENBQUM7Z0JBQzFELElBQUksQ0FBQyxZQUFZLENBQUMsWUFBWSxFQUFFLENBQUM7WUFDckMsQ0FBQyxDQUFDLENBQUM7WUFDSCxZQUFZLENBQUMsSUFBSSxDQUFDLG1CQUFtQixDQUFDLENBQUM7UUFDM0MsQ0FBQztRQUFBLENBQUM7UUFDRixPQUFPLENBQUMsQ0FBQyxDQUFDLEdBQUcsQ0FBQyxZQUFZLENBQUM7YUFDdEIsSUFBSSxDQUFDO1lBQ0YsSUFBSSxDQUFDLE9BQU8sRUFBRSxDQUFDO1FBQ25CLENBQUMsQ0FBQyxDQUFDO1FBRVAsTUFBTSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUM7SUFDeEIsQ0FBQzs7QUFDTCxDQUFDO0FBNURZLG1CQUFXLGNBNER2QixDQUFBO0FBQUEsQ0FBQyJ9

View File

@ -1,25 +0,0 @@
/// <reference types="q" />
import * as plugins from "./smartnginx.plugins";
/**
* the host config data that NginxHost needs to create a valid instance
*/
export interface IHostConfigData {
hostName: string;
type: hostTypes;
destination: string;
}
export declare enum hostTypes {
reverseProxy = 0,
static = 1,
}
/**
* manages a single nginx host
*/
export declare class NginxHost {
hostName: string;
type: hostTypes;
destination: string;
configString: string;
constructor(optionsArg: IHostConfigData);
deploy(certInstanceArg: plugins.cert.Cert): plugins.q.Promise<{}>;
}

View File

@ -1,35 +0,0 @@
"use strict";
const plugins = require("./smartnginx.plugins");
const paths = require("./smartnginx.paths");
const snippets = require("./smartnginx.snippets");
(function (hostTypes) {
hostTypes[hostTypes["reverseProxy"] = 0] = "reverseProxy";
hostTypes[hostTypes["static"] = 1] = "static";
})(exports.hostTypes || (exports.hostTypes = {}));
var hostTypes = exports.hostTypes;
/**
* manages a single nginx host
*/
class NginxHost {
constructor(optionsArg) {
this.hostName = optionsArg.hostName;
this.type = optionsArg.type;
this.destination = optionsArg.destination;
this.configString = snippets.getHostConfigString(optionsArg.hostName, optionsArg.destination);
}
;
deploy(certInstanceArg) {
let done = plugins.q.defer();
let filePath = plugins.path.join(paths.nginxHostFileBase, this.hostName + ".conf");
// writeConfig
plugins.smartfile.memory.toFsSync(this.configString, filePath);
// get cert
certInstanceArg.getDomainCert(this.hostName)
.then(done.resolve);
return done.promise;
}
;
}
exports.NginxHost = NginxHost;
;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRuZ2lueC5jbGFzc2VzLm5naW54aG9zdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0bmdpbnguY2xhc3Nlcy5uZ2lueGhvc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLE1BQVksT0FBTyxXQUFNLHNCQUFzQixDQUFDLENBQUE7QUFDaEQsTUFBWSxLQUFLLFdBQU0sb0JBQW9CLENBQUMsQ0FBQTtBQUM1QyxNQUFZLFFBQVEsV0FBTSx1QkFLMUIsQ0FBQyxDQUxnRDtBQVdqRCxXQUFZLFNBQVM7SUFDakIseURBQVksQ0FBQTtJQUNaLDZDQUFNLENBQUE7QUFDVixDQUFDLEVBSFcsaUJBQVMsS0FBVCxpQkFBUyxRQUdwQjtBQUhELElBQVksU0FBUyxHQUFULGlCQUdYLENBQUE7QUFFRDs7R0FFRztBQUNIO0lBS0ksWUFBWSxVQUEwQjtRQUNsQyxJQUFJLENBQUMsUUFBUSxHQUFHLFVBQVUsQ0FBQyxRQUFRLENBQUM7UUFDcEMsSUFBSSxDQUFDLElBQUksR0FBRyxVQUFVLENBQUMsSUFBSSxDQUFDO1FBQzVCLElBQUksQ0FBQyxXQUFXLEdBQUcsVUFBVSxDQUFDLFdBQVcsQ0FBQztRQUMxQyxJQUFJLENBQUMsWUFBWSxHQUFHLFFBQVEsQ0FBQyxtQkFBbUIsQ0FBQyxVQUFVLENBQUMsUUFBUSxFQUFFLFVBQVUsQ0FBQyxXQUFXLENBQUMsQ0FBQztJQUNsRyxDQUFDOztJQUNELE1BQU0sQ0FBQyxlQUFrQztRQUNyQyxJQUFJLElBQUksR0FBRyxPQUFPLENBQUMsQ0FBQyxDQUFDLEtBQUssRUFBRSxDQUFDO1FBQzdCLElBQUksUUFBUSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLEtBQUssQ0FBQyxpQkFBaUIsRUFBRSxJQUFJLENBQUMsUUFBUSxHQUFHLE9BQU8sQ0FBQyxDQUFDO1FBQ25GLGNBQWM7UUFDZCxPQUFPLENBQUMsU0FBUyxDQUFDLE1BQU0sQ0FBQyxRQUFRLENBQUMsSUFBSSxDQUFDLFlBQVksRUFBRSxRQUFRLENBQUMsQ0FBQztRQUMvRCxXQUFXO1FBQ1gsZUFBZSxDQUFDLGFBQWEsQ0FBQyxJQUFJLENBQUMsUUFBUSxDQUFDO2FBQ3ZDLElBQUksQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDLENBQUM7UUFDeEIsTUFBTSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUM7SUFDeEIsQ0FBQzs7QUFDTCxDQUFDO0FBckJZLGlCQUFTLFlBcUJyQixDQUFBO0FBQUEsQ0FBQyJ9

View File

@ -1,29 +0,0 @@
/// <reference types="node" />
/// <reference types="q" />
import * as plugins from "./smartnginx.plugins";
import { NginxConfig } from "./smartnginx.classes.nginxconfig";
/**
* manages a nginxprocess for an NginxConfig
*/
export declare class NginxProcess {
started: boolean;
nginxConfig: NginxConfig;
nginxChildProcess: plugins.childProcess.ChildProcess;
constructor(nginxConfigArg: any);
/**
* start nginx
*/
start(): plugins.q.Promise<{}>;
/**
* reload config
*/
reloadConfig(): plugins.q.Promise<{}>;
/**
* stop the nginx instance
*/
stop(): plugins.q.Promise<{}>;
/**
* checks if nginx is in path
*/
check(): boolean;
}

View File

@ -1,79 +0,0 @@
"use strict";
const plugins = require("./smartnginx.plugins");
const paths = require("./smartnginx.paths");
/**
* manages a nginxprocess for an NginxConfig
*/
class NginxProcess {
constructor(nginxConfigArg) {
this.started = false;
this.nginxConfig = nginxConfigArg;
}
;
/**
* start nginx
*/
start() {
let done = plugins.q.defer();
if (typeof this.nginxChildProcess == "undefined") {
this.nginxChildProcess = plugins.childProcess.exec(`nginx -c ${paths.nginxConfFile}`, function (error, stdout, stderr) {
console.log(`stdout: ${stdout}`);
console.log(`stderr: ${stderr}`);
if (error !== null) {
console.log(`exec error: ${error}`);
}
;
});
}
;
this.started = true;
plugins.beautylog.info("started Nginx!");
done.resolve();
return done.promise;
}
;
/**
* reload config
*/
reloadConfig() {
let done = plugins.q.defer();
if (this.started == false) {
this.start();
}
else {
plugins.shelljs.exec("nginx -s reload");
}
;
plugins.beautylog.ok("NginxProcess has loaded the new config!");
done.resolve();
return done.promise;
}
;
/**
* stop the nginx instance
*/
stop() {
let done = plugins.q.defer();
if (typeof this.nginxChildProcess != "undefined") {
plugins.shelljs.exec("nginx -s quit");
this.started = false;
plugins.beautylog.info("stopped Nginx!");
}
else {
plugins.beautylog.log("nginx already stopped!");
}
;
done.resolve();
return done.promise;
}
;
/**
* checks if nginx is in path
*/
check() {
return;
}
;
}
exports.NginxProcess = NginxProcess;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRuZ2lueC5jbGFzc2VzLm5naW54cHJvY2Vzcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0bmdpbnguY2xhc3Nlcy5uZ2lueHByb2Nlc3MudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLE1BQVksT0FBTyxXQUFNLHNCQUFzQixDQUFDLENBQUE7QUFDaEQsTUFBWSxLQUFLLFdBQU0sb0JBQW9CLENBQUMsQ0FBQTtBQUk1Qzs7R0FFRztBQUNIO0lBSUksWUFBWSxjQUFjO1FBSDFCLFlBQU8sR0FBWSxLQUFLL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QUFDO1FBQ2YsTUFBTSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUM7SUFDeEIsQ0FBQzs7SUFFRDs7T0FFRztJQUNILEtBQUs7UUFDRCxNQUFNLENBQUM7SUFDWCxDQUFDOztBQUNMLENBQUM7QUFqRVksb0JBQVksZUFpRXhCLENBQUEifQ==

View File

@ -1,5 +0,0 @@
export declare let packageBase: string;
export declare let nginxConfigBase: string;
export declare let nginxHostFileBase: string;
export declare let nginxCertBase: string;
export declare let nginxConfFile: string;

View File

@ -1,10 +0,0 @@
"use strict";
const plugins = require("./smartnginx.plugins");
// directories
exports.packageBase = plugins.path.join(__dirname, "../");
exports.nginxConfigBase = plugins.path.join(exports.packageBase, "nginxconfig");
exports.nginxHostFileBase = plugins.path.join(exports.nginxConfigBase, "hosts");
exports.nginxCertBase = plugins.path.join(exports.nginxConfigBase, "cert");
// files
exports.nginxConfFile = plugins.path.join(exports.nginxConfigBase, "nginx.conf");
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRuZ2lueC5wYXRocy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0bmdpbngucGF0aHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLE1BQVksT0FBTyxXQUFNLHNCQUd6QixDQUFDLENBSDhDO0FBRS9DLGNBQWM7QUFDSCxtQkFBVyxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLFNBQVMsRUFBQyxLQUFLLENBQUMsQ0FBQztBQUNqRCx1QkFBZSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLG1CQUFXLEVBQUMsYUFBYSxDQUFDLENBQUM7QUFDL0QseUJBQWlCLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsdUJBQWUsRUFBQyxPQUFPLENBQUMsQ0FBQztBQUMvRCxxQkFBYSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLHVCQUFlLEVBQUMsTUFBTSxDQUFDLENBQUM7QUFFckUsUUFBUTtBQUNHLHFCQUFhLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsdUJBQWUsRUFBQyxZQUFZLENBQUMsQ0FBQyJ9

View File

@ -1,9 +0,0 @@
import "typings-global";
export import beautylog = require("beautylog");
export import cert = require("cert");
export import childProcess = require("child_process");
export import path = require("path");
export import q = require("q");
export import shelljs = require("shelljs");
export import smartfile = require("smartfile");
export import smartstring = require("smartstring");

View File

@ -1,11 +0,0 @@
"use strict";
require("typings-global");
exports.beautylog = require("beautylog");
exports.cert = require("cert");
exports.childProcess = require("child_process");
exports.path = require("path");
exports.q = require("q");
exports.shelljs = require("shelljs");
exports.smartfile = require("smartfile");
exports.smartstring = require("smartstring");
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRuZ2lueC5wbHVnaW5zLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRuZ2lueC5wbHVnaW5zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUFnQixDQUFDLENBQUE7QUFDVixpQkFBUyxXQUFXLFdBQVcsQ0FBQyxDQUFDO0FBQ2pDLFlBQUksV0FBVyxNQUFNLENBQUMsQ0FBQztBQUN2QixvQkFBWSxXQUFXLGVBQWUsQ0FBQyxDQUFDO0FBQ3hDLFlBQUksV0FBVyxNQUFNLENBQUMsQ0FBQztBQUN2QixTQUFDLFdBQVcsR0FBRyxDQUFDLENBQUM7QUFDakIsZUFBTyxXQUFXLFNBQVMsQ0FBQyxDQUFDO0FBQzdCLGlCQUFTLFdBQVcsV0FBVyxDQUFDLENBQUM7QUFDakMsbUJBQVcsV0FBVyxhQUFhLENBQUMsQ0FBQyJ9

View File

@ -1,2 +0,0 @@
export declare let getBaseConfigString: () => string;
export declare let getHostConfigString: (hostNameArg: string, destinationIpArg: string) => string;

View File

@ -1,103 +0,0 @@
"use strict";
const plugins = require("./smartnginx.plugins");
const paths = require("./smartnginx.paths");
exports.getBaseConfigString = () => {
let baseConfig = plugins.smartstring.indent.normalize(`
user www-data;
worker_processes auto;
pid /run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
server_names_hash_bucket_size 128;
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
##
# Virtual Host Configs
##
include ${paths.nginxHostFileBase}/*.conf;
include /etc/nginx/sites-enabled/*;
}
daemon off;
`);
return baseConfig;
};
exports.getHostConfigString = (hostNameArg, destinationIpArg) => {
let hostConfig = plugins.smartstring.indent.normalize(`
upstream ${hostNameArg} {
server ${destinationIpArg};
}
server {
listen *:80 ;
server_name ${hostNameArg};
rewrite ^ https://${hostNameArg}$request_uri? permanent;
}
server {
listen *:443 ssl;
server_name ${hostNameArg};
ssl_certificate ${paths.nginxCertBase}/${hostNameArg}/fullchain.pem;
ssl_certificate_key ${paths.nginxCertBase}/${hostNameArg}/privkey.pem;
location / {
proxy_pass http://${hostNameArg};
include /etc/nginx/proxy_params;
}
location ~ /\.git {
deny all;
}
}
`);
return hostConfig;
};
//# sour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{
"name": "@pushrocks/smartnginx",
"version": "2.0.14",
"version": "2.0.47",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@ -90,9 +90,9 @@
}
},
"@pushrocks/qenv": {
"version": "3.0.2",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fqenv/-/qenv-3.0.2.tgz",
"integrity": "sha512-gXW9Cib6izqY7W1MssryFBrjIoKwadftjv5G3y/BE4LboCkGazqjMJsea6z6G79rwvX1M+yxEEcIdIsDvBBSiA==",
"version": "4.0.0",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fqenv/-/qenv-4.0.0.tgz",
"integrity": "sha512-3/odPJaGp3ALtcSG/+N3dGtFX/CVBed9a5XKDa0bv7LoKCgYZeQwpF3jkCnNPjs7GKyzOzALHHID1L+zcb1RXw==",
"dev": true,
"requires": {
"@pushrocks/smartfile": "^6.0.6",
@ -162,11 +162,11 @@
}
},
"@pushrocks/smartlog": {
"version": "2.0.9",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartlog/-/smartlog-2.0.9.tgz",
"integrity": "sha512-F2u3O8OOQ7QXgg9o0lI7HnqEhSQZo2A8u0EuNbQH+Kj2oL62xDwjAg6KkINwH7ObSWpaldZ+I28prG0JxaRzvg==",
"version": "2.0.11",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartlog/-/smartlog-2.0.11.tgz",
"integrity": "sha512-V8SMzAAqDpl1+CJ9b3w5e/1ARjk4JOPZ35qZIllVBhHr8meCqnPE2immlfBYWmEp1xy3ntdAA+Lgewtu+iVk6A==",
"requires": {
"@pushrocks/smartlog-interfaces": "^2.0.2"
"@pushrocks/smartlog-interfaces": "^2.0.5"
}
},
"@pushrocks/smartlog-interfaces": {
@ -227,12 +227,12 @@
}
},
"@pushrocks/smartstring": {
"version": "3.0.5",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartstring/-/smartstring-3.0.5.tgz",
"integrity": "sha512-Bws2s6+Pc0HIXA35QH6cl6LJywhZ1U5icjyYMx+1kH8nURG+njzkacfarr9NWqyVYYOVu7SgXLzp9sR0eH7k9g==",
"version": "3.0.8",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartstring/-/smartstring-3.0.8.tgz",
"integrity": "sha512-twmCGF47+TJoiCpj6t5MxwcKDDJEATuKqJXxftcHOlXWW743LJ/1bCpMueDdtumo5EheUfSxb43aRse3DU3wig==",
"requires": {
"crypto-random-string": "^1.0.0",
"js-base64": "^2.4.9",
"js-base64": "^2.5.0",
"normalize-newline": "^3.0.0",
"randomatic": "^3.1.1",
"strip-indent": "^2.0.0"
@ -248,6 +248,17 @@
"luxon": "^1.8.0"
}
},
"@pushrocks/smartunique": {
"version": "3.0.1",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartunique/-/smartunique-3.0.1.tgz",
"integrity": "sha512-xBu9ZB4C0BA0S/pbFFZn2ItPfnodPKpzrYIq1yN5XDs6OaookwcDF/iBwfS9+EYMSPENC9wAsOxg2RGMm4Qicw==",
"requires": {
"@types/shortid": "^0.0.29",
"@types/uuid": "^3.0.0",
"shortid": "^2.2.8",
"uuid": "^3.1.0"
}
},
"@pushrocks/tapbundle": {
"version": "3.0.7",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2ftapbundle/-/tapbundle-3.0.7.tgz",
@ -322,6 +333,19 @@
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.5.7.tgz",
"integrity": "sha512-VkKcfuitP+Nc/TaTFH0B8qNmn+6NbI6crLkQonbedViVz7O2w8QV/GERPlkJ4bg42VGHiEWa31CoTOPs1q6z1w=="
},
"@types/shortid": {
"version": "0.0.29",
"resolved": "https://verdaccio.lossless.one/@types%2fshortid/-/shortid-0.0.29.tgz",
"integrity": "sha1-gJPuBBam4r8qpjOBCRFLP7/6Dps="
},
"@types/uuid": {
"version": "3.4.4",
"resolved": "https://verdaccio.lossless.one/@types%2fuuid/-/uuid-3.4.4.tgz",
"integrity": "sha512-tPIgT0GUmdJQNSHxp0X2jnpQfBSTfGxUMc/2CXBU2mnyTFVYVa2ojpoQ74w0U2yn2vw3jnC640+77lkFFpdVDw==",
"requires": {
"@types/node": "*"
}
},
"@types/vinyl": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/@types/vinyl/-/vinyl-2.0.2.tgz",
@ -332,7 +356,7 @@
},
"@types/which": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/@types/which/-/which-1.3.1.tgz",
"resolved": "https://verdaccio.lossless.one/@types%2fwhich/-/which-1.3.1.tgz",
"integrity": "sha512-ZrJDWpvg75LTGX4XwuneY9s6bF3OeZcGTpoGh3zDV9ytzcHMFsRrMIaLBRJZQMBoGyKs6unBQfVdrLZiYfb1zQ=="
},
"@types/yargs": {
@ -595,9 +619,9 @@
}
},
"commander": {
"version": "2.19.0",
"resolved": "https://verdaccio.lossless.one/commander/-/commander-2.19.0.tgz",
"integrity": "sha512-6tvAOO+D6OENvRAh524Dh9jcfKTYDQAqvqezbCW82xj5X0pSrcpxtvRKHLG0yBY6SD7PSDrJaj+0AiOcKVd1Xg==",
"version": "2.20.0",
"resolved": "https://verdaccio.lossless.one/commander/-/commander-2.20.0.tgz",
"integrity": "sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ==",
"dev": true
},
"concat-map": {
@ -774,9 +798,9 @@
}
},
"glob": {
"version": "7.1.2",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz",
"integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==",
"version": "7.1.3",
"resolved": "https://verdaccio.lossless.one/glob/-/glob-7.1.3.tgz",
"integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==",
"dev": true,
"requires": {
"fs.realpath": "^1.0.0",
@ -965,9 +989,9 @@
}
},
"math-random": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/math-random/-/math-random-1.0.1.tgz",
"integrity": "sha1-izqsWIuKZuSXXjzepn97sylgH6w="
"version": "1.0.4",
"resolved": "https://verdaccio.lossless.one/math-random/-/math-random-1.0.4.tgz",
"integrity": "sha512-rUxjysqif/BZQH2yhd5Aaq7vXMSx9NdEsQcyA07uEzIvxgI7zIr33gGsh+RU0/XjmQpCW7RsVof1vlkvQVCK5A=="
},
"mem": {
"version": "4.0.0",
@ -1036,12 +1060,22 @@
"integrity": "sha512-JY7V6lRkStKcKTvHO5NVSQRv+RV+FIL5pvDoLiAtSL9pKlC5x9PKQcZDsq7m4FO4d57mkhC6Z+QhAh3Jdk5JFw==",
"dev": true
},
"nanoid": {
"version": "2.0.1",
"resolved": "https://verdaccio.lossless.one/nanoid/-/nanoid-2.0.1.tgz",
"integrity": "sha512-k1u2uemjIGsn25zmujKnotgniC/gxQ9sdegdezeDiKdkDW56THUMqlz3urndKCXJxA6yPzSZbXx/QCMe/pxqsA=="
},
"nice-try": {
"version": "1.0.5",
"resolved": "https://verdaccio.lossless.one/nice-try/-/nice-try-1.0.5.tgz",
"integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==",
"dev": true
},
"node-forge": {
"version": "0.7.5",
"resolved": "https://verdaccio.lossless.one/node-forge/-/node-forge-0.7.5.tgz",
"integrity": "sha512-MmbQJ2MTESTjt3Gi/3yG1wGpIMhUfcIypUCGtTizFR9IiccFwxSpfp0vtIZlkFclEqERemxfnSdZEMR9VqqEFQ=="
},
"normalize-newline": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/normalize-newline/-/normalize-newline-3.0.0.tgz",
@ -1225,9 +1259,9 @@
"dev": true
},
"resolve": {
"version": "1.9.0",
"resolved": "https://verdaccio.lossless.one/resolve/-/resolve-1.9.0.tgz",
"integrity": "sha512-TZNye00tI67lwYvzxCxHGjwTNlUV70io54/Ed4j6PscB8xVfuBJpRenI/o6dVk0cY0PYTY27AgCoGGxRnYuItQ==",
"version": "1.10.0",
"resolved": "https://verdaccio.lossless.one/resolve/-/resolve-1.10.0.tgz",
"integrity": "sha512-3sUr9aq5OfSg2S9pNtPA9hL1FVEAjvfOC4leW0SNf/mpnaakz2a9femSd6LqAww2RaFctwyf1lCqnTHuF1rxDg==",
"dev": true,
"requires": {
"path-parse": "^1.0.6"
@ -1246,6 +1280,14 @@
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
},
"selfsigned": {
"version": "1.10.4",
"resolved": "https://verdaccio.lossless.one/selfsigned/-/selfsigned-1.10.4.tgz",
"integrity": "sha512-9AukTiDmHXGXWtWjembZ5NDmVvP2695EtpgbCsxCa68w3c88B+alqbmZ4O3hZ4VWGXeGWzEVdvqgAJD8DQPCDw==",
"requires": {
"node-forge": "0.7.5"
}
},
"semver": {
"version": "5.6.0",
"resolved": "https://verdaccio.lossless.one/semver/-/semver-5.6.0.tgz",
@ -1273,6 +1315,14 @@
"integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=",
"dev": true
},
"shortid": {
"version": "2.2.14",
"resolved": "https://verdaccio.lossless.one/shortid/-/shortid-2.2.14.tgz",
"integrity": "sha512-4UnZgr9gDdA1kaKj/38IiudfC3KHKhDc1zi/HSxd9FQDR0VLwH3/y79tZJLsVYPsJgIjeHjqIWaWVRJUj9qZOQ==",
"requires": {
"nanoid": "^2.0.0"
}
},
"signal-exit": {
"version": "3.0.2",
"resolved": "https://verdaccio.lossless.one/signal-exit/-/signal-exit-3.0.2.tgz",
@ -1410,9 +1460,9 @@
"integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ=="
},
"tslint": {
"version": "5.12.0",
"resolved": "https://verdaccio.lossless.one/tslint/-/tslint-5.12.0.tgz",
"integrity": "sha512-CKEcH1MHUBhoV43SA/Jmy1l24HJJgI0eyLbBNSRyFlsQvb9v6Zdq+Nz2vEOH00nC5SUx4SneJ59PZUS/ARcokQ==",
"version": "5.15.0",
"resolved": "https://verdaccio.lossless.one/tslint/-/tslint-5.15.0.tgz",
"integrity": "sha512-6bIEujKR21/3nyeoX2uBnE8s+tMXCQXhqMmaIPJpHmXJoBJPTLcI7/VHRtUwMhnLVdwLqqY3zmd8Dxqa5CVdJA==",
"dev": true,
"requires": {
"babel-code-frame": "^6.22.0",
@ -1421,18 +1471,31 @@
"commander": "^2.12.1",
"diff": "^3.2.0",
"glob": "^7.1.1",
"js-yaml": "^3.7.0",
"js-yaml": "^3.13.0",
"minimatch": "^3.0.4",
"mkdirp": "^0.5.1",
"resolve": "^1.3.2",
"semver": "^5.3.0",
"tslib": "^1.8.0",
"tsutils": "^2.27.2"
"tsutils": "^2.29.0"
},
"dependencies": {
"js-yaml": {
"version": "3.13.1",
"resolved": "https://verdaccio.lossless.one/js-yaml/-/js-yaml-3.13.1.tgz",
"integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==",
"dev": true,
"requires": {
"argparse": "^1.0.7",
"esprima": "^4.0.0"
}
}
}
},
"tslint-config-prettier": {
"version": "1.17.0",
"resolved": "https://verdaccio.lossless.one/tslint-config-prettier/-/tslint-config-prettier-1.17.0.tgz",
"integrity": "sha512-NKWNkThwqE4Snn4Cm6SZB7lV5RMDDFsBwz6fWUkTxOKGjMx8ycOHnjIbhn7dZd5XmssW3CwqUjlANR6EhP9YQw==",
"version": "1.18.0",
"resolved": "https://verdaccio.lossless.one/tslint-config-prettier/-/tslint-config-prettier-1.18.0.tgz",
"integrity": "sha512-xPw9PgNPLG3iKRxmK7DWr+Ea/SzrvfHtjFt5LBl61gk2UBG/DB9kCXRjv+xyIU1rUtnayLeMUVJBcMX8Z17nDg==",
"dev": true
},
"tsutils": {
@ -1466,6 +1529,11 @@
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
"integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
},
"uuid": {
"version": "3.3.2",
"resolved": "https://verdaccio.lossless.one/uuid/-/uuid-3.3.2.tgz",
"integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA=="
},
"vinyl": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/vinyl/-/vinyl-2.2.0.tgz",

View File

@ -1,6 +1,6 @@
{
"name": "@pushrocks/smartnginx",
"version": "2.0.14",
"version": "2.0.47",
"private": false,
"description": "control nginx from node, TypeScript ready",
"main": "dist/index.js",
@ -26,18 +26,20 @@
"dependencies": {
"@pushrocks/lik": "^3.0.4",
"@pushrocks/smartfile": "^6.0.11",
"@pushrocks/smartlog": "^2.0.9",
"@pushrocks/smartlog": "^2.0.11",
"@pushrocks/smartpromise": "^2.0.5",
"@pushrocks/smartshell": "^2.0.13",
"@pushrocks/smartstring": "^3.0.5"
"@pushrocks/smartstring": "^3.0.8",
"@pushrocks/smartunique": "^3.0.1",
"selfsigned": "^1.10.4"
},
"devDependencies": {
"@gitzone/tsbuild": "^2.1.4",
"@gitzone/tsrun": "^1.1.17",
"@gitzone/tstest": "^1.0.18",
"@pushrocks/qenv": "^3.0.2",
"@pushrocks/qenv": "^4.0.0",
"@pushrocks/tapbundle": "^3.0.7",
"tslint": "^5.12.0",
"tslint-config-prettier": "^1.17.0"
"tslint": "^5.15.0",
"tslint-config-prettier": "^1.18.0"
}
}

View File

@ -1 +1 @@
vars:
required:

View File

@ -11,7 +11,7 @@ let testNginxZone01: smartnginx.NginxHost;
let testNginxZone02: smartnginx.NginxHost;
tap.test('should create a valid instance of SmartNginx', async () => {
testSmartNginx = new smartnginx.SmartNginx({});
testSmartNginx = new smartnginx.SmartNginx({defaultProxyUrl: 'https://git.zone'});
expect(testSmartNginx).to.be.instanceof(smartnginx.SmartNginx);
});
@ -19,27 +19,35 @@ tap.test(`should produce an instance of NginxConfig`, async () => {
testNginxZone01 = new smartnginx.NginxHost(testSmartNginx, {
hostName: 'test100.bleu.de',
destination: '192.192.192.191',
destinationPort: 3000,
privateKey: 'some private',
publicKey: 'some public'
});
testNginxZone02 = new smartnginx.NginxHost(testSmartNginx, {
hostName: 'test102.bleu.de',
destination: '192.192.192.192',
destinationPort: 3050,
privateKey: 'some private',
publicKey: 'some public'
});
expect(testNginxZone01).to.be.instanceof(smartnginx.NginxHost);
});
tap.test('.addZone() should add a zone to NginxConfig Object', async () => {
testSmartNginx.addHost(testNginxZone01);
testSmartNginx.addHost(testNginxZone02);
tap.test('.addHostCandidate() should add a zone to NginxConfig Object', async () => {
testSmartNginx.addHostCandidate(testNginxZone01);
testSmartNginx.addHostCandidate(testNginxZone02);
});
tap.test('.deploy() should deploy a config from an instance', async () => {
await testSmartNginx.deploy();
});
tap.test('should not redeploy', async () => {
testSmartNginx.addHostCandidate(testNginxZone01);
testSmartNginx.addHostCandidate(testNginxZone02);
await testSmartNginx.deploy();
});
tap.test('.stop() should end the process', async () => {
testSmartNginx.nginxProcess.stop();
});

View File

@ -1,6 +1,7 @@
export interface IHostConfig {
hostName: string;
destination: string;
destinationPort: number;
privateKey: string;
publicKey: string;
}

View File

@ -17,19 +17,20 @@ export class NginxHost implements IHostConfig {
/**
* smartnginxInstance this NginHost belongs to
*/
smartnginxInstance: SmartNginx;
public smartnginxInstance: SmartNginx;
hostName: string; // the host name e.g. domain name
destination: string;
configString: string; // the actual host config file as string
privateKey: string;
publicKey: string;
public hostName: string; // the host name e.g. domain name
public destination: string;
public destinationPort: number;
public configString: string; // the actual host config file as string
public privateKey: string;
public publicKey: string;
constructor(smartnginxInstanceArg: SmartNginx, optionsArg: IHostConfig) {
this.smartnginxInstance = smartnginxInstanceArg;
this.hostName = optionsArg.hostName;
this.destination = optionsArg.destination;
this.configString = snippets.getHostConfigString(optionsArg.hostName, optionsArg.destination);
this.destinationPort = optionsArg.destinationPort;
this.privateKey = optionsArg.privateKey;
this.publicKey = optionsArg.publicKey;
}
@ -42,7 +43,10 @@ export class NginxHost implements IHostConfig {
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);
plugins.smartfile.memory.toFsSync(this.configString, filePathConfig);
// write ssl

View File

@ -5,16 +5,27 @@ import { NginxHost } from './smartnginx.classes.nginxhost';
import { NginxProcess } from './smartnginx.classes.nginxprocess';
import { IHostConfig } from './interfaces/hostconfig';
export interface ISmartNginxContructorOptions {
logger?: plugins.smartlog.Smartlog;
defaultProxyUrl: string;
}
/**
* main class that manages a NginxInstance
*/
export class SmartNginx {
public options: ISmartNginxContructorOptions;
public logger: plugins.smartlog.Smartlog;
private hosts = new plugins.lik.Objectmap<NginxHost>();
// the objectmaps
private deployedHosts = new plugins.lik.Objectmap<NginxHost>();
private hostCandidates = new plugins.lik.Objectmap<NginxHost>();
public nginxProcess: NginxProcess = new NginxProcess(this);
constructor(optionsArg: { logger?: plugins.smartlog.Smartlog }) {
optionsArg.logger
? (this.logger = optionsArg.logger)
constructor(optionsArg: ISmartNginxContructorOptions) {
this.options = optionsArg;
this.options.logger
? (this.logger = this.options.logger)
: (this.logger = plugins.smartlog.defaultLogger);
}
@ -26,9 +37,9 @@ export class SmartNginx {
* add a host
* @param nginxHostArg
*/
public addHost(optionsArg: IHostConfig): NginxHost {
public addHostCandidate(optionsArg: IHostConfig): NginxHost {
const nginxHost = new NginxHost(this, optionsArg);
this.hosts.add(nginxHost);
this.hostCandidates.add(nginxHost);
return nginxHost;
}
@ -36,47 +47,91 @@ export class SmartNginx {
* Gets a NginxHost by hostname
* @param hostNameArg
*/
public getNginxHostByHostName(hostNameArg: string): NginxHost {
return this.hosts.find(nginxHost => {
public getDeployedNginxHostByHostName(hostNameArg: string): NginxHost {
return this.deployedHosts.find(nginxHost => {
return nginxHost.hostName === hostNameArg;
});
}
/**
* listHosts
*/
public listHosts(): NginxHost[] {
return this.hosts.getArray();
public async listDeployedHosts(): Promise<NginxHost[]> {
return this.deployedHosts.getArray();
}
/**
* remove a Host
* @param nginxHostArg
*/
public removeHost(nginxHostArg: NginxHost) {
this.hosts.remove(nginxHostArg);
public async removeDeployedHost(nginxHostArg: NginxHost) {
if (this.hostCandidates.isEmpty()) {
this.deployedHosts.forEach(hostArg => {
this.hostCandidates.add(hostArg);
});
}
this.hostCandidates.remove(nginxHostArg);
this.deploy();
}
/**
* clean all hosts
* check wether there has been a diverging host configuration
* this function will only redeploy the nginx configuration in case there has been a change
*/
public wipeHosts() {
this.hosts.wipe();
private async areHostsDiverged(): Promise<boolean> {
let hostCounter = 0;
let unfoundHosts = 0;
await this.hostCandidates.forEach(async hostCandidateArg => {
let foundHost = false;
await this.deployedHosts.forEach(async deployedHostArg => {
if (
hostCandidateArg.hostName === deployedHostArg.hostName &&
hostCandidateArg.destination === deployedHostArg.destination &&
hostCandidateArg.destinationPort === deployedHostArg.destinationPort
) {
hostCounter++;
foundHost = true;
}
});
if (!foundHost) {
unfoundHosts++;
}
});
return (
this.deployedHosts.getArray().length !== this.hostCandidates.getArray().length ||
hostCounter !== this.deployedHosts.getArray().length ||
unfoundHosts !== 0
);
}
/**
* deploy the current stack and restart nginx
*/
public async deploy() {
// write base config
plugins.smartfile.fs.ensureDirSync(paths.nginxConfigDirPath);
plugins.smartfile.memory.toFsSync(snippets.getBaseConfigString(), paths.nginxConfFile);
if (await this.areHostsDiverged()) {
this.logger.log('ok', `hosts have diverged, trigger config deployment and nginx reload!`);
this.deployedHosts.wipe();
this.deployedHosts.addArray(this.hostCandidates.getArray());
this.hostCandidates.wipe();
// deploy hosts
plugins.smartfile.fs.ensureEmptyDirSync(paths.nginxHostDirPath);
for (const host of this.hosts.getArray()) {
await host.deploy();
this.logger.log('info', `Host ${host.hostName} deployed!`);
// write base config
plugins.smartfile.fs.ensureDirSync(paths.nginxConfigDirPath);
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});
// 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'));
for (const host of this.deployedHosts.getArray()) {
await host.deploy();
this.logger.log('info', `Host ${host.hostName} deployed!`);
}
this.nginxProcess.reloadConfig();
} else {
this.logger.log('info', `hosts have not diverged, skipping nginx reload`);
this.hostCandidates.wipe();
}
this.nginxProcess.reloadConfig();
}
}

View File

@ -10,5 +10,13 @@ import * as smartpromise from '@pushrocks/smartpromise';
import * as smartshell from '@pushrocks/smartshell';
import * as smartfile from '@pushrocks/smartfile';
import * as smartstring from '@pushrocks/smartstring';
import * as smartunique from '@pushrocks/smartunique';
export { lik, smartlog, smartpromise, smartshell, smartfile, smartstring };
export { lik, smartlog, smartpromise, smartshell, smartfile, smartstring, smartunique };
// thirdparty scope
import * as selfsigned from 'selfsigned';
export {
selfsigned
};

View File

@ -1,7 +1,7 @@
import * as plugins from './smartnginx.plugins';
import * as paths from './smartnginx.paths';
export let getBaseConfigString = () => {
let baseConfig = plugins.smartstring.indent.normalize(`
export let getBaseConfigString = (defaultProxy: string) => {
const baseConfig = plugins.smartstring.indent.normalize(`
user www-data;
worker_processes auto;
pid /run/nginx/nginx.pid;
@ -63,6 +63,20 @@ export let getBaseConfigString = () => {
# Virtual Host Configs
##
server {
listen *:80 default_server;
server_name selfsigned.git.zone;
rewrite ^ ${defaultProxy} permanent;
}
server {
listen *:443 ssl default_server;
server_name selfsigned.git.zone;
ssl_certificate ${paths.nginxHostDirPath}/default.public.pem;
ssl_certificate_key ${paths.nginxHostDirPath}/default.private.pem;
rewrite ^ ${defaultProxy} permanent;
}
include ${paths.nginxHostDirPath}/*.conf;
include /etc/nginx/sites-enabled/*;
}
@ -71,13 +85,17 @@ export let getBaseConfigString = () => {
return baseConfig;
};
export let getHostConfigString = (hostNameArg: string, destinationIpArg: string) => {
let hostConfig = plugins.smartstring.indent.normalize(`
export let getHostConfigString = (hostNameArg: string, destinationIpArg: string, destinationPortArg = 80) => {
const hostConfig = plugins.smartstring.indent.normalize(`
upstream ${hostNameArg} {
server ${destinationIpArg};
keepalive 100;
server ${destinationIpArg}:${destinationPortArg};
}
server {
# The keepalive parameter sets the maximum number of idle keepalive connections
# to upstream servers that are preserved in the cache of each worker process. When
# this number is exceeded, the least recently used connections are closed.
listen *:80 ;
server_name ${hostNameArg};
rewrite ^ https://${hostNameArg}$request_uri? permanent;
@ -88,16 +106,16 @@ export let getHostConfigString = (hostNameArg: string, destinationIpArg: string)
server_name ${hostNameArg};
ssl_certificate ${paths.nginxHostDirPath}/${hostNameArg}.public.pem;
ssl_certificate_key ${paths.nginxHostDirPath}/${hostNameArg}.private.pem;
location / {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://${hostNameArg};
}
location ~ /\.git {
deny all;
proxy_http_version 1.1;
proxy_buffering off;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_next_upstream error timeout http_404 http_429 http_500 http_502;
proxy_next_upstream_tries 5;
proxy_pass http://${hostNameArg};
}
}
`);