consolidate naming and start exporting interfaces
This commit is contained in:
parent
d8a4c3d088
commit
c3c2ab776d
6
dist/index.d.ts
vendored
6
dist/index.d.ts
vendored
@ -1,3 +1,3 @@
|
|||||||
export { NginxConfig } from "./smartnginx.classes.nginxconfig";
|
export * from "./smartnginx.classes.nginxconfig";
|
||||||
export { NginxProcess } from "./smartnginx.classes.nginxprocess";
|
export * from "./smartnginx.classes.nginxprocess";
|
||||||
export { NginxZone, zoneTypes } from "./smartnginx.classes.nginxzone";
|
export * from "./smartnginx.classes.nginxhost";
|
||||||
|
15
dist/index.js
vendored
15
dist/index.js
vendored
@ -1,10 +1,9 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
function __export(m) {
|
||||||
|
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
||||||
|
}
|
||||||
// classes
|
// classes
|
||||||
var smartnginx_classes_nginxconfig_1 = require("./smartnginx.classes.nginxconfig");
|
__export(require("./smartnginx.classes.nginxconfig"));
|
||||||
exports.NginxConfig = smartnginx_classes_nginxconfig_1.NginxConfig;
|
__export(require("./smartnginx.classes.nginxprocess"));
|
||||||
var smartnginx_classes_nginxprocess_1 = require("./smartnginx.classes.nginxprocess");
|
__export(require("./smartnginx.classes.nginxhost"));
|
||||||
exports.NginxProcess = smartnginx_classes_nginxprocess_1.NginxProcess;
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7O0FBRUEsVUFBVTtBQUNWLGlCQUFjLGtDQUFrQyxDQUFDLEVBQUE7QUFDakQsaUJBQWMsbUNBQW1DLENBQUMsRUFBQTtBQUNsRCxpQkFBYyxnQ0FBZ0MsQ0FBQyxFQUFBIn0=
|
||||||
var smartnginx_classes_nginxzone_1 = require("./smartnginx.classes.nginxzone");
|
|
||||||
exports.NginxZone = smartnginx_classes_nginxzone_1.NginxZone;
|
|
||||||
exports.zoneTypes = smartnginx_classes_nginxzone_1.zoneTypes;
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBRUEsVUFBVTtBQUNWLCtDQUEwQixrQ0FBa0MsQ0FBQztBQUFyRCxtRUFBcUQ7QUFDN0QsZ0RBQTJCLG1DQUFtQyxDQUFDO0FBQXZELHNFQUF1RDtBQUMvRCw2Q0FBa0MsZ0NBQWdDLENBQUM7QUFBM0QsNkRBQVM7QUFBQyw2REFBaUQifQ==
|
|
13
dist/smartnginx.classes.nginxconfig.d.ts
vendored
13
dist/smartnginx.classes.nginxconfig.d.ts
vendored
@ -1,16 +1,19 @@
|
|||||||
/// <reference types="q" />
|
/// <reference types="q" />
|
||||||
import * as plugins from "./smartnginx.plugins";
|
import * as plugins from "./smartnginx.plugins";
|
||||||
import { NginxZone } from "./smartnginx.classes.nginxzone";
|
import { NginxHost } from "./smartnginx.classes.nginxhost";
|
||||||
import { NginxProcess } from "./smartnginx.classes.nginxprocess";
|
import { NginxProcess } from "./smartnginx.classes.nginxprocess";
|
||||||
|
/**
|
||||||
|
* main class that manages a NginxInstance
|
||||||
|
*/
|
||||||
export declare class NginxConfig {
|
export declare class NginxConfig {
|
||||||
zones: NginxZone[];
|
hosts: NginxHost[];
|
||||||
cert: plugins.cert.Cert;
|
cert: plugins.cert.Cert;
|
||||||
nginxProcess: NginxProcess;
|
nginxProcess: NginxProcess;
|
||||||
isDeployed: boolean;
|
isDeployed: boolean;
|
||||||
constructor(optionsArg: plugins.cert.ICertConstructorOptions);
|
constructor(optionsArg: plugins.cert.ICertConstructorOptions);
|
||||||
addZone(zoneArg: NginxZone): void;
|
addHost(nginxHostArg: NginxHost): void;
|
||||||
listZones(): NginxZone[];
|
listHosts(): NginxHost[];
|
||||||
removeZones(zoneArg: NginxZone): void;
|
removeHost(nginxHostArg: NginxHost): void;
|
||||||
clean(): void;
|
clean(): void;
|
||||||
deploy(): plugins.q.Promise<{}>;
|
deploy(): plugins.q.Promise<{}>;
|
||||||
}
|
}
|
||||||
|
37
dist/smartnginx.classes.nginxconfig.js
vendored
37
dist/smartnginx.classes.nginxconfig.js
vendored
@ -4,9 +4,12 @@ const paths = require("./smartnginx.paths");
|
|||||||
const snippets = require("./smartnginx.snippets");
|
const snippets = require("./smartnginx.snippets");
|
||||||
const smartnginx_classes_nginxprocess_1 = require("./smartnginx.classes.nginxprocess");
|
const smartnginx_classes_nginxprocess_1 = require("./smartnginx.classes.nginxprocess");
|
||||||
let allConfigs = [];
|
let allConfigs = [];
|
||||||
|
/**
|
||||||
|
* main class that manages a NginxInstance
|
||||||
|
*/
|
||||||
class NginxConfig {
|
class NginxConfig {
|
||||||
constructor(optionsArg) {
|
constructor(optionsArg) {
|
||||||
this.zones = [];
|
this.hosts = [];
|
||||||
this.nginxProcess = new smartnginx_classes_nginxprocess_1.NginxProcess(this);
|
this.nginxProcess = new smartnginx_classes_nginxprocess_1.NginxProcess(this);
|
||||||
this.isDeployed = false;
|
this.isDeployed = false;
|
||||||
this.cert = new plugins.cert.Cert({
|
this.cert = new plugins.cert.Cert({
|
||||||
@ -18,24 +21,24 @@ class NginxConfig {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
// interact with Zones
|
// interact with Hosts
|
||||||
addZone(zoneArg) {
|
addHost(nginxHostArg) {
|
||||||
this.zones.push(zoneArg);
|
this.hosts.push(nginxHostArg);
|
||||||
}
|
}
|
||||||
listZones() {
|
listHosts() {
|
||||||
return this.zones;
|
return this.hosts;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
removeZones(zoneArg) {
|
removeHost(nginxHostArg) {
|
||||||
}
|
}
|
||||||
clean() {
|
clean() {
|
||||||
this.zones = [];
|
this.hosts = [];
|
||||||
}
|
}
|
||||||
// handle deployment of zones
|
// handle deployment of hosts
|
||||||
deploy() {
|
deploy() {
|
||||||
let done = plugins.q.defer();
|
let done = plugins.q.defer();
|
||||||
plugins.smartfile.fs.ensureDirSync(paths.nginxConfigBase);
|
plugins.smartfile.fs.ensureDirSync(paths.nginxConfigBase);
|
||||||
plugins.smartfile.fs.ensureDirSync(paths.nginxZoneBase);
|
plugins.smartfile.fs.ensureDirSync(paths.nginxHostFileBase);
|
||||||
plugins.smartfile.fs.ensureDirSync(paths.nginxCertBase);
|
plugins.smartfile.fs.ensureDirSync(paths.nginxCertBase);
|
||||||
for (let config of allConfigs) {
|
for (let config of allConfigs) {
|
||||||
config.isDeployed = false;
|
config.isDeployed = false;
|
||||||
@ -44,15 +47,15 @@ class NginxConfig {
|
|||||||
this.isDeployed = true;
|
this.isDeployed = true;
|
||||||
// write base config
|
// write base config
|
||||||
plugins.smartfile.memory.toFsSync(snippets.getBaseConfigString(), paths.nginxConfFile);
|
plugins.smartfile.memory.toFsSync(snippets.getBaseConfigString(), paths.nginxConfFile);
|
||||||
// deploy zones
|
// deploy hosts
|
||||||
let promiseArray = [];
|
let promiseArray = [];
|
||||||
for (let zone of this.zones) {
|
for (let host of this.hosts) {
|
||||||
let zoneDeployedPromise = zone.deploy(this.cert);
|
let hostDeployedPromise = host.deploy(this.cert);
|
||||||
zoneDeployedPromise.then(() => {
|
hostDeployedPromise.then(() => {
|
||||||
plugins.beautylog.info(`Zone ${zone.zoneName} deployed!`);
|
plugins.beautylog.info(`Host ${host.hostName} deployed!`);
|
||||||
this.nginxProcess.reloadConfig();
|
this.nginxProcess.reloadConfig();
|
||||||
});
|
});
|
||||||
promiseArray.push(zoneDeployedPromise);
|
promiseArray.push(hostDeployedPromise);
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
plugins.q.all(promiseArray)
|
plugins.q.all(promiseArray)
|
||||||
@ -65,4 +68,4 @@ class NginxConfig {
|
|||||||
}
|
}
|
||||||
exports.NginxConfig = NginxConfig;
|
exports.NginxConfig = NginxConfig;
|
||||||
;
|
;
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRuZ2lueC5jbGFzc2VzLm5naW54Y29uZmlnLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRuZ2lueC5jbGFzc2VzLm5naW54Y29uZmlnLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxNQUFZLE9BQU8sV0FBTSxzQkFBc0IsQ0FBQyxDQUFBO0FBQ2hELE1BQVksS0FBSyxXQUFNLG9CQUFvQixDQUFDLENBQUE7QUFDNUMsTUFBWSxRQUFRLFdBQU0sdUJBQXVCLENBQUMsQ0FBQTtBQUVsRCxrREFBNkIsbUNBQW1DLENBQUMsQ0FBQTtBQUNqRSxJQUFJLFVBQVUsR0FBa0IsRUFBRSxDQUFDO0FBRW5DO0lBS0ksWUFBWSxVQUFnRDtRQUo1RCxVQUFLLEdBQWdCLEVBQUUsQ0FBQztRQUV4QixpQkFBWSxHQUFpQixJQUFJLDhDQUFZLENBQUMsSUFBSSxDQUFDLENBQUM7UUFDcEQsZUFBVSxHQUFZLEtBQUssQ0FBQztRQUV4QixJQUFJLENBQUMsSUFBSSxHQUFHLElBQUksT0FBTyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUM7WUFDOUIsT0FBTyxFQUFFLFVBQVUsQ0FBQyxPQUFPO1lBQzNCLEtBQUssRUFBRSxVQUFVLENBQUMsS0FBSztZQUN2QixNQUFNLEVBQUUsS0FBSyxDQUFDLGFBQWE7WUFDM0IsYUFBYSxFQUFFLFVBQVUsQ0FBQyxhQUFhO1lBQ3ZDLFFBQVEsRUFBRSxVQUFVLENBQUMsUUFBUTtTQUNoQyxDQUFDLENBQUM7SUFDUCxDQUFDOztJQUVELHNCQUFzQjtJQUN0QixPQUFPLENBQUMsT0FBa0I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UM7Z0JBQzFELElBQUksQ0FBQyxZQUFZLENBQUMsWUFBWSxFQUFFLENBQUM7WUFDckMsQ0FBQyxDQUFDLENBQUM7WUFDSCxZQUFZLENBQUMsSUFBSSxDQUFDLG1CQUFtQixDQUFDLENBQUM7UUFDM0MsQ0FBQztRQUFBLENBQUM7UUFDRixPQUFPLENBQUMsQ0FBQyxDQUFDLEdBQUcsQ0FBQyxZQUFZLENBQUM7YUFDdEIsSUFBSSxDQUFDO1lBQ0YsSUFBSSxDQUFDLE9BQU8sRUFBRSxDQUFDO1FBQ25CLENBQUMsQ0FBQyxDQUFDO1FBRVAsTUFBTSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUM7SUFDeEIsQ0FBQzs7QUFDTCxDQUFDO0FBNURZLG1CQUFXLGNBNER2QixDQUFBO0FBQUEsQ0FBQyJ9
|
25
dist/smartnginx.classes.nginxhost.d.ts
vendored
Normal file
25
dist/smartnginx.classes.nginxhost.d.ts
vendored
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
/// <reference types="q" />
|
||||||
|
import * as plugins from "./smartnginx.plugins";
|
||||||
|
/**
|
||||||
|
* the host config data that NginxHost needs to create a valid instance
|
||||||
|
*/
|
||||||
|
export interface hostConfigData {
|
||||||
|
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: hostConfigData);
|
||||||
|
deploy(certInstanceArg: plugins.cert.Cert): plugins.q.Promise<{}>;
|
||||||
|
}
|
35
dist/smartnginx.classes.nginxhost.js
vendored
Normal file
35
dist/smartnginx.classes.nginxhost.js
vendored
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
"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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRuZ2lueC5jbGFzc2VzLm5naW54aG9zdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0bmdpbnguY2xhc3Nlcy5uZ2lueGhvc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLE1BQVksT0FBTyxXQUFNLHNCQUFzQixDQUFDLENBQUE7QUFDaEQsTUFBWS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xDQUFDO2FBQ3ZDLElBQUksQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDLENBQUM7UUFDeEIsTUFBTSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUM7SUFDeEIsQ0FBQzs7QUFDTCxDQUFDO0FBckJZLGlCQUFTLFlBcUJyQixDQUFBO0FBQUEsQ0FBQyJ9
|
3
dist/smartnginx.classes.nginxprocess.d.ts
vendored
3
dist/smartnginx.classes.nginxprocess.d.ts
vendored
@ -2,6 +2,9 @@
|
|||||||
/// <reference types="q" />
|
/// <reference types="q" />
|
||||||
import * as plugins from "./smartnginx.plugins";
|
import * as plugins from "./smartnginx.plugins";
|
||||||
import { NginxConfig } from "./smartnginx.classes.nginxconfig";
|
import { NginxConfig } from "./smartnginx.classes.nginxconfig";
|
||||||
|
/**
|
||||||
|
* manages a nginxprocess for an NginxConfig
|
||||||
|
*/
|
||||||
export declare class NginxProcess {
|
export declare class NginxProcess {
|
||||||
started: boolean;
|
started: boolean;
|
||||||
nginxConfig: NginxConfig;
|
nginxConfig: NginxConfig;
|
||||||
|
5
dist/smartnginx.classes.nginxprocess.js
vendored
5
dist/smartnginx.classes.nginxprocess.js
vendored
@ -1,6 +1,9 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
const plugins = require("./smartnginx.plugins");
|
const plugins = require("./smartnginx.plugins");
|
||||||
const paths = require("./smartnginx.paths");
|
const paths = require("./smartnginx.paths");
|
||||||
|
/**
|
||||||
|
* manages a nginxprocess for an NginxConfig
|
||||||
|
*/
|
||||||
class NginxProcess {
|
class NginxProcess {
|
||||||
constructor(nginxConfigArg) {
|
constructor(nginxConfigArg) {
|
||||||
this.started = false;
|
this.started = false;
|
||||||
@ -73,4 +76,4 @@ class NginxProcess {
|
|||||||
;
|
;
|
||||||
}
|
}
|
||||||
exports.NginxProcess = NginxProcess;
|
exports.NginxProcess = NginxProcess;
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21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QUFDOztBQUNMLENBQUM7QUFqRVksb0JBQVksZUFpRXhCLENBQUEifQ==
|
18
dist/smartnginx.classes.nginxzone.d.ts
vendored
18
dist/smartnginx.classes.nginxzone.d.ts
vendored
@ -1,18 +0,0 @@
|
|||||||
/// <reference types="q" />
|
|
||||||
import * as plugins from "./smartnginx.plugins";
|
|
||||||
export declare enum zoneTypes {
|
|
||||||
reverseProxy = 0,
|
|
||||||
static = 1,
|
|
||||||
}
|
|
||||||
export declare class NginxZone {
|
|
||||||
zoneName: string;
|
|
||||||
type: zoneTypes;
|
|
||||||
destination: string;
|
|
||||||
configString: string;
|
|
||||||
constructor(optionsArg: {
|
|
||||||
zoneName: string;
|
|
||||||
type: zoneTypes;
|
|
||||||
destination: string;
|
|
||||||
});
|
|
||||||
deploy(certInstanceArg: plugins.cert.Cert): plugins.q.Promise<{}>;
|
|
||||||
}
|
|
32
dist/smartnginx.classes.nginxzone.js
vendored
32
dist/smartnginx.classes.nginxzone.js
vendored
@ -1,32 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
const plugins = require("./smartnginx.plugins");
|
|
||||||
const paths = require("./smartnginx.paths");
|
|
||||||
const snippets = require("./smartnginx.snippets");
|
|
||||||
(function (zoneTypes) {
|
|
||||||
zoneTypes[zoneTypes["reverseProxy"] = 0] = "reverseProxy";
|
|
||||||
zoneTypes[zoneTypes["static"] = 1] = "static";
|
|
||||||
})(exports.zoneTypes || (exports.zoneTypes = {}));
|
|
||||||
var zoneTypes = exports.zoneTypes;
|
|
||||||
class NginxZone {
|
|
||||||
constructor(optionsArg) {
|
|
||||||
this.zoneName = optionsArg.zoneName;
|
|
||||||
this.type = optionsArg.type;
|
|
||||||
this.destination = optionsArg.destination;
|
|
||||||
this.configString = snippets.getZoneConfigString(optionsArg.zoneName, optionsArg.destination);
|
|
||||||
}
|
|
||||||
;
|
|
||||||
deploy(certInstanceArg) {
|
|
||||||
let done = plugins.q.defer();
|
|
||||||
let filePath = plugins.path.join(paths.nginxZoneBase, this.zoneName + ".conf");
|
|
||||||
// writeConfig
|
|
||||||
plugins.smartfile.memory.toFsSync(this.configString, filePath);
|
|
||||||
// get cert
|
|
||||||
certInstanceArg.getDomainCert(this.zoneName)
|
|
||||||
.then(done.resolve);
|
|
||||||
return done.promise;
|
|
||||||
}
|
|
||||||
;
|
|
||||||
}
|
|
||||||
exports.NginxZone = NginxZone;
|
|
||||||
;
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRuZ2lueC5jbGFzc2VzLm5naW54em9uZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0bmdpbnguY2xhc3Nlcy5uZ2lueHpvbmUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLE1BQVksT0FBTyxXQUFNLHNCQUFzQixDQUFDLENBQUE7QUFDaEQsTUFBWSxLQUFLLFdBQU0sb0JBQW9CLENBQUMsQ0FBQTtBQUM1QyxNQUFZLFFBQVEsV0FBTSx1QkFDMUIsQ0FBQyxDQURnRDtBQUNqRCxXQUFZLFNBQVM7SUFDakIseURBQVksQ0FBQTtJQUNaLDZDQUFNLENBQUE7QUFDVixDQUFDLEVBSFcsaUJBQVMsS0FBVCxpQkFBUyxRQUdwQjtBQUhELElBQVksU0FBUyxHQUFULGlCQUdYLENBQUE7QUFFRDtJQUtJLFlBQVksVUFJWDtRQUNHLElBQUksQ0FBQyxRQUFRLEdBQUcsVUFBVSxDQUFDLFFBQVEsQ0FBQztRQUNwQyxJQUFJLENBQUMsSUFBSSxHQUFHLFVBQVUsQ0FBQyxJQUFJLENBQUM7UUFDNUIsSUFBSSxDQUFDLFdBQVcsR0FBRyxVQUFVLENBQUMsV0FBVyxDQUFDO1FBQzFDLElBQUksQ0FBQyxZQUFZLEdBQUcsUUFBUSxDQUFDLG1CQUFtQixDQUFDLFVBQVUsQ0FBQyxRQUFRLEVBQUUsVUFBVSxDQUFDLFdBQVcsQ0FBQyxDQUFDO0lBQ2xHLENBQUM7O0lBQ0QsTUFBTSxDQUFDLGVBQWtDO1FBQ3JDLElBQUksSUFBSSxHQUFHLE9BQU8sQ0FBQyxDQUFDLENBQUMsS0FBSyxFQUFFLENBQUM7UUFDN0IsSUFBSSxRQUFRLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsS0FBSyxDQUFDLGFBQWEsRUFBRSxJQUFJLENBQUMsUUFBUSxHQUFHLE9BQU8sQ0FBQyxDQUFDO1FBQy9FLGNBQWM7UUFDZCxPQUFPLENBQUMsU0FBUyxDQUFDLE1BQU0sQ0FBQyxRQUFRLENBQUMsSUFBSSxDQUFDLFlBQVksRUFBRSxRQUFRLENBQUMsQ0FBQztRQUMvRCxXQUFXO1FBQ1gsZUFBZSxDQUFDLGFBQWEsQ0FBQyxJQUFJLENBQUMsUUFBUSxDQUFDO2FBQ3ZDLElBQUksQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDLENBQUM7UUFDeEIsTUFBTSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUM7SUFDeEIsQ0FBQzs7QUFDTCxDQUFDO0FBekJZLGlCQUFTLFlBeUJyQixDQUFBO0FBQUEsQ0FBQyJ9
|
|
2
dist/smartnginx.paths.d.ts
vendored
2
dist/smartnginx.paths.d.ts
vendored
@ -1,5 +1,5 @@
|
|||||||
export declare let packageBase: string;
|
export declare let packageBase: string;
|
||||||
export declare let nginxConfigBase: string;
|
export declare let nginxConfigBase: string;
|
||||||
export declare let nginxZoneBase: string;
|
export declare let nginxHostFileBase: string;
|
||||||
export declare let nginxCertBase: string;
|
export declare let nginxCertBase: string;
|
||||||
export declare let nginxConfFile: string;
|
export declare let nginxConfFile: string;
|
||||||
|
4
dist/smartnginx.paths.js
vendored
4
dist/smartnginx.paths.js
vendored
@ -3,8 +3,8 @@ const plugins = require("./smartnginx.plugins");
|
|||||||
// directories
|
// directories
|
||||||
exports.packageBase = plugins.path.join(__dirname, "../");
|
exports.packageBase = plugins.path.join(__dirname, "../");
|
||||||
exports.nginxConfigBase = plugins.path.join(exports.packageBase, "nginxconfig");
|
exports.nginxConfigBase = plugins.path.join(exports.packageBase, "nginxconfig");
|
||||||
exports.nginxZoneBase = plugins.path.join(exports.nginxConfigBase, "zones");
|
exports.nginxHostFileBase = plugins.path.join(exports.nginxConfigBase, "hosts");
|
||||||
exports.nginxCertBase = plugins.path.join(exports.nginxConfigBase, "cert");
|
exports.nginxCertBase = plugins.path.join(exports.nginxConfigBase, "cert");
|
||||||
// files
|
// files
|
||||||
exports.nginxConfFile = plugins.path.join(exports.nginxConfigBase, "nginx.conf");
|
exports.nginxConfFile = plugins.path.join(exports.nginxConfigBase, "nginx.conf");
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRuZ2lueC5wYXRocy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0bmdpbngucGF0aHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLE1BQVksT0FBTyxXQUFNLHNCQUd6QixDQUFDLENBSDhDO0FBRS9DLGNBQWM7QUFDSCxtQkFBVyxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLFNBQVMsRUFBQyxLQUFLLENBQUMsQ0FBQztBQUNqRCx1QkFBZSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLG1CQUFXLEVBQUMsYUFBYSxDQUFDLENBQUM7QUFDL0QscUJBQWEsR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyx1QkFBZSxFQUFDLE9BQU8sQ0FBQyxDQUFDO0FBQzNELHFCQUFhLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsdUJBQWUsRUFBQyxNQUFNLENBQUMsQ0FBQztBQUVyRSxRQUFRO0FBQ0cscUJBQWEsR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyx1QkFBZSxFQUFDLFlBQVksQ0FBQyxDQUFDIn0=
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRuZ2lueC5wYXRocy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0bmdpbngucGF0aHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLE1BQVksT0FBTyxXQUFNLHNCQUd6QixDQUFDLENBSDhDO0FBRS9DLGNBQWM7QUFDSCxtQkFBVyxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLFNBQVMsRUFBQyxLQUFLLENBQUMsQ0FBQztBQUNqRCx1QkFBZSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLG1CQUFXLEVBQUMsYUFBYSxDQUFDLENBQUM7QUFDL0QseUJBQWlCLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsdUJBQWUsRUFBQyxPQUFPLENBQUMsQ0FBQztBQUMvRCxxQkFBYSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLHVCQUFlLEVBQUMsTUFBTSxDQUFDLENBQUM7QUFFckUsUUFBUTtBQUNHLHFCQUFhLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsdUJBQWUsRUFBQyxZQUFZLENBQUMsQ0FBQyJ9
|
2
dist/smartnginx.snippets.d.ts
vendored
2
dist/smartnginx.snippets.d.ts
vendored
@ -1,2 +1,2 @@
|
|||||||
export declare let getBaseConfigString: () => string;
|
export declare let getBaseConfigString: () => string;
|
||||||
export declare let getZoneConfigString: (zoneNameArg: string, destinationIpArg: string) => string;
|
export declare let getHostConfigString: (hostNameArg: string, destinationIpArg: string) => string;
|
||||||
|
20
dist/smartnginx.snippets.js
vendored
20
dist/smartnginx.snippets.js
vendored
@ -70,26 +70,26 @@ exports.getBaseConfigString = () => {
|
|||||||
`);
|
`);
|
||||||
return baseConfig;
|
return baseConfig;
|
||||||
};
|
};
|
||||||
exports.getZoneConfigString = (zoneNameArg, destinationIpArg) => {
|
exports.getHostConfigString = (hostNameArg, destinationIpArg) => {
|
||||||
let zoneConfig = plugins.smartstring.indent.normalize(`
|
let hostConfig = plugins.smartstring.indent.normalize(`
|
||||||
upstream ${zoneNameArg} {
|
upstream ${hostNameArg} {
|
||||||
server ${destinationIpArg};
|
server ${destinationIpArg};
|
||||||
}
|
}
|
||||||
|
|
||||||
server {
|
server {
|
||||||
listen *:80 ;
|
listen *:80 ;
|
||||||
server_name ${zoneNameArg};
|
server_name ${hostNameArg};
|
||||||
rewrite ^ https://${zoneNameArg}$request_uri? permanent;
|
rewrite ^ https://${hostNameArg}$request_uri? permanent;
|
||||||
}
|
}
|
||||||
|
|
||||||
server {
|
server {
|
||||||
listen *:443 ssl;
|
listen *:443 ssl;
|
||||||
server_name ${zoneNameArg};
|
server_name ${hostNameArg};
|
||||||
ssl_certificate /LE_CERTS/${zoneNameArg}/fullchain.pem;
|
ssl_certificate /LE_CERTS/${hostNameArg}/fullchain.pem;
|
||||||
ssl_certificate_key /LE_CERTS/${zoneNameArg}/privkey.pem;
|
ssl_certificate_key /LE_CERTS/${hostNameArg}/privkey.pem;
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
proxy_pass http://${zoneNameArg};
|
proxy_pass http://${hostNameArg};
|
||||||
include /etc/nginx/proxy_params;
|
include /etc/nginx/proxy_params;
|
||||||
}
|
}
|
||||||
location ~ /\.git {
|
location ~ /\.git {
|
||||||
@ -97,6 +97,6 @@ exports.getZoneConfigString = (zoneNameArg, destinationIpArg) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
`);
|
`);
|
||||||
return zoneConfig;
|
return hostConfig;
|
||||||
};
|
};
|
||||||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XSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLE1BQVksT0FBTyxXQUFNLHNCQUFzQixDQUFDLENBQUE7QUFDckMsMkJBQW1CLEdBQUc7SUFDaEMsSUFBSSxVQUFVLEdBQUcsT0FBTyxDQUFDLFdBQVcsQ0FBQyxNQUFNLENBQUMsU0FBUyxDQUFDOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7RUFrRXJELENBQUMsQ0FBQztJQUNILE1BQU0sQ0FBQyxVQUFVLENBQUM7QUFDbkIsQ0FBQyxDQUFBO0FBR1UsMkJBQW1CLEdBQUcsQ0FBQyxXQUFrQixFQUFDLGdCQUF1QjtJQUMzRSxJQUFJLFVBQVUsR0FBRyxPQUFPLENBQUMsV0FBVyxDQUFDLE1BQU0sQ0FBQyxTQUFTLENBQUM7YUFDMUMsV0FBVztZQUNaLGdCQUFnQjs7Ozs7aUJBS1gsV0FBVzs4QkFDRSxXQUFXOzs7OztpQkFLeEIsV0FBVzsrQkFDRyxXQUFXO21DQUNQLFdBQVc7Ozt3QkFHdEIsV0FBVzs7Ozs7OztFQU9qQyxDQUFDLENBQUM7SUFDSCxNQUFNLENBQUMsVUFBVSxDQUFDO0FBQ25CLENBQUMsQ0FBQyJ9
|
18
test/test.js
18
test/test.js
@ -12,17 +12,17 @@ describe("smartnginx", function () {
|
|||||||
let testNginxZone02;
|
let testNginxZone02;
|
||||||
describe("NginxZone", function () {
|
describe("NginxZone", function () {
|
||||||
it(`"new NginxZone()" should produce an instance of NginxConfig`, function () {
|
it(`"new NginxZone()" should produce an instance of NginxConfig`, function () {
|
||||||
testNginxZone01 = new smartnginx.NginxZone({
|
testNginxZone01 = new smartnginx.NginxHost({
|
||||||
zoneName: "test100.bleu.de",
|
hostName: "test100.bleu.de",
|
||||||
type: smartnginx.zoneTypes.reverseProxy,
|
type: smartnginx.hostTypes.reverseProxy,
|
||||||
destination: "192.192.192.191"
|
destination: "192.192.192.191"
|
||||||
});
|
});
|
||||||
testNginxZone02 = new smartnginx.NginxZone({
|
testNginxZone02 = new smartnginx.NginxHost({
|
||||||
zoneName: "test102.bleu.de",
|
hostName: "test102.bleu.de",
|
||||||
type: smartnginx.zoneTypes.reverseProxy,
|
type: smartnginx.hostTypes.reverseProxy,
|
||||||
destination: "192.192.192.192"
|
destination: "192.192.192.192"
|
||||||
});
|
});
|
||||||
testNginxZone01.should.be.instanceof(smartnginx.NginxZone);
|
testNginxZone01.should.be.instanceof(smartnginx.NginxHost);
|
||||||
console.log(testNginxZone01.configString);
|
console.log(testNginxZone01.configString);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -38,8 +38,8 @@ describe("smartnginx", function () {
|
|||||||
});
|
});
|
||||||
describe(".addZone()", function () {
|
describe(".addZone()", function () {
|
||||||
it("should add a zone to NginxConfig Object", function () {
|
it("should add a zone to NginxConfig Object", function () {
|
||||||
testNginxConfig.addZone(testNginxZone01);
|
testNginxConfig.addHost(testNginxZone01);
|
||||||
testNginxConfig.addZone(testNginxZone02);
|
testNginxConfig.addHost(testNginxZone02);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe(".deploy()", function () {
|
describe(".deploy()", function () {
|
||||||
|
22
test/test.ts
22
test/test.ts
@ -8,21 +8,21 @@ import * as smartnginx from "../dist/index";
|
|||||||
let testQenv = new Qenv(process.cwd(),path.join(process.cwd(),".nogit"));
|
let testQenv = new Qenv(process.cwd(),path.join(process.cwd(),".nogit"));
|
||||||
describe("smartnginx",function(){
|
describe("smartnginx",function(){
|
||||||
let testNginxConfig:smartnginx.NginxConfig;
|
let testNginxConfig:smartnginx.NginxConfig;
|
||||||
let testNginxZone01:smartnginx.NginxZone;
|
let testNginxZone01:smartnginx.NginxHost;
|
||||||
let testNginxZone02:smartnginx.NginxZone;
|
let testNginxZone02:smartnginx.NginxHost;
|
||||||
describe("NginxZone",function(){
|
describe("NginxZone",function(){
|
||||||
it(`"new NginxZone()" should produce an instance of NginxConfig`,function(){
|
it(`"new NginxZone()" should produce an instance of NginxConfig`,function(){
|
||||||
testNginxZone01 = new smartnginx.NginxZone({
|
testNginxZone01 = new smartnginx.NginxHost({
|
||||||
zoneName:"test100.bleu.de",
|
hostName:"test100.bleu.de",
|
||||||
type:smartnginx.zoneTypes.reverseProxy,
|
type:smartnginx.hostTypes.reverseProxy,
|
||||||
destination:"192.192.192.191"
|
destination:"192.192.192.191"
|
||||||
});
|
});
|
||||||
testNginxZone02 = new smartnginx.NginxZone({
|
testNginxZone02 = new smartnginx.NginxHost({
|
||||||
zoneName:"test102.bleu.de",
|
hostName:"test102.bleu.de",
|
||||||
type:smartnginx.zoneTypes.reverseProxy,
|
type:smartnginx.hostTypes.reverseProxy,
|
||||||
destination:"192.192.192.192"
|
destination:"192.192.192.192"
|
||||||
});
|
});
|
||||||
testNginxZone01.should.be.instanceof(smartnginx.NginxZone);
|
testNginxZone01.should.be.instanceof(smartnginx.NginxHost);
|
||||||
console.log(testNginxZone01.configString);
|
console.log(testNginxZone01.configString);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -38,8 +38,8 @@ describe("smartnginx",function(){
|
|||||||
});
|
});
|
||||||
describe(".addZone()",function(){
|
describe(".addZone()",function(){
|
||||||
it("should add a zone to NginxConfig Object",function(){
|
it("should add a zone to NginxConfig Object",function(){
|
||||||
testNginxConfig.addZone(testNginxZone01);
|
testNginxConfig.addHost(testNginxZone01);
|
||||||
testNginxConfig.addZone(testNginxZone02);
|
testNginxConfig.addHost(testNginxZone02);
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
describe(".deploy()",function(){
|
describe(".deploy()",function(){
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import * as plugins from "./smartnginx.plugins";
|
import * as plugins from "./smartnginx.plugins";
|
||||||
|
|
||||||
// classes
|
// classes
|
||||||
export {NginxConfig} from "./smartnginx.classes.nginxconfig";
|
export * from "./smartnginx.classes.nginxconfig";
|
||||||
export {NginxProcess} from "./smartnginx.classes.nginxprocess";
|
export * from "./smartnginx.classes.nginxprocess";
|
||||||
export {NginxZone,zoneTypes} from "./smartnginx.classes.nginxzone";
|
export * from "./smartnginx.classes.nginxhost";
|
@ -1,12 +1,15 @@
|
|||||||
import * as plugins from "./smartnginx.plugins";
|
import * as plugins from "./smartnginx.plugins";
|
||||||
import * as paths from "./smartnginx.paths";
|
import * as paths from "./smartnginx.paths";
|
||||||
import * as snippets from "./smartnginx.snippets";
|
import * as snippets from "./smartnginx.snippets";
|
||||||
import { NginxZone } from "./smartnginx.classes.nginxzone";
|
import { NginxHost } from "./smartnginx.classes.nginxhost";
|
||||||
import { NginxProcess } from "./smartnginx.classes.nginxprocess";
|
import { NginxProcess } from "./smartnginx.classes.nginxprocess";
|
||||||
let allConfigs: NginxConfig[] = [];
|
let allConfigs: NginxConfig[] = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* main class that manages a NginxInstance
|
||||||
|
*/
|
||||||
export class NginxConfig {
|
export class NginxConfig {
|
||||||
zones: NginxZone[] = [];
|
hosts: NginxHost[] = [];
|
||||||
cert: plugins.cert.Cert; // the Cert Instance from which the config gets its certificates
|
cert: plugins.cert.Cert; // the Cert Instance from which the config gets its certificates
|
||||||
nginxProcess: NginxProcess = new NginxProcess(this);
|
nginxProcess: NginxProcess = new NginxProcess(this);
|
||||||
isDeployed: boolean = false;
|
isDeployed: boolean = false;
|
||||||
@ -20,24 +23,24 @@ export class NginxConfig {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// interact with Zones
|
// interact with Hosts
|
||||||
addZone(zoneArg: NginxZone){
|
addHost(nginxHostArg: NginxHost){
|
||||||
this.zones.push(zoneArg);
|
this.hosts.push(nginxHostArg);
|
||||||
}
|
}
|
||||||
listZones(): NginxZone[]{
|
listHosts(): NginxHost[]{
|
||||||
return this.zones;
|
return this.hosts;
|
||||||
};
|
};
|
||||||
removeZones(zoneArg: NginxZone) {
|
removeHost(nginxHostArg: NginxHost) {
|
||||||
|
|
||||||
}
|
}
|
||||||
clean() {
|
clean() {
|
||||||
this.zones = [];
|
this.hosts = [];
|
||||||
}
|
}
|
||||||
// handle deployment of zones
|
// handle deployment of hosts
|
||||||
deploy() {
|
deploy() {
|
||||||
let done = plugins.q.defer();
|
let done = plugins.q.defer();
|
||||||
plugins.smartfile.fs.ensureDirSync(paths.nginxConfigBase);
|
plugins.smartfile.fs.ensureDirSync(paths.nginxConfigBase);
|
||||||
plugins.smartfile.fs.ensureDirSync(paths.nginxZoneBase);
|
plugins.smartfile.fs.ensureDirSync(paths.nginxHostFileBase);
|
||||||
plugins.smartfile.fs.ensureDirSync(paths.nginxCertBase);
|
plugins.smartfile.fs.ensureDirSync(paths.nginxCertBase);
|
||||||
for (let config of allConfigs) {
|
for (let config of allConfigs) {
|
||||||
config.isDeployed = false;
|
config.isDeployed = false;
|
||||||
@ -48,15 +51,15 @@ export class NginxConfig {
|
|||||||
snippets.getBaseConfigString(),
|
snippets.getBaseConfigString(),
|
||||||
paths.nginxConfFile
|
paths.nginxConfFile
|
||||||
);
|
);
|
||||||
// deploy zones
|
// deploy hosts
|
||||||
let promiseArray = [];
|
let promiseArray = [];
|
||||||
for (let zone of this.zones) {
|
for (let host of this.hosts) {
|
||||||
let zoneDeployedPromise = zone.deploy(this.cert);
|
let hostDeployedPromise = host.deploy(this.cert);
|
||||||
zoneDeployedPromise.then(() => {
|
hostDeployedPromise.then(() => {
|
||||||
plugins.beautylog.info(`Zone ${zone.zoneName} deployed!`);
|
plugins.beautylog.info(`Host ${host.hostName} deployed!`);
|
||||||
this.nginxProcess.reloadConfig();
|
this.nginxProcess.reloadConfig();
|
||||||
});
|
});
|
||||||
promiseArray.push(zoneDeployedPromise);
|
promiseArray.push(hostDeployedPromise);
|
||||||
};
|
};
|
||||||
plugins.q.all(promiseArray)
|
plugins.q.all(promiseArray)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
43
ts/smartnginx.classes.nginxhost.ts
Normal file
43
ts/smartnginx.classes.nginxhost.ts
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
import * as plugins from "./smartnginx.plugins";
|
||||||
|
import * as paths from "./smartnginx.paths";
|
||||||
|
import * as snippets from "./smartnginx.snippets"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* the host config data that NginxHost needs to create a valid instance
|
||||||
|
*/
|
||||||
|
export interface hostConfigData {
|
||||||
|
hostName: string,
|
||||||
|
type: hostTypes,
|
||||||
|
destination: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum hostTypes {
|
||||||
|
reverseProxy,
|
||||||
|
static
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* manages a single nginx host
|
||||||
|
*/
|
||||||
|
export class NginxHost {
|
||||||
|
hostName: string; // the host name e.g. domain name
|
||||||
|
type: hostTypes;
|
||||||
|
destination: string;
|
||||||
|
configString: string; // the actual host config file as string
|
||||||
|
constructor(optionsArg:hostConfigData) {
|
||||||
|
this.hostName = optionsArg.hostName;
|
||||||
|
this.type = optionsArg.type;
|
||||||
|
this.destination = optionsArg.destination;
|
||||||
|
this.configString = snippets.getHostConfigString(optionsArg.hostName, optionsArg.destination);
|
||||||
|
};
|
||||||
|
deploy(certInstanceArg: plugins.cert.Cert) {
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
};
|
@ -1,8 +1,11 @@
|
|||||||
import * as plugins from "./smartnginx.plugins";
|
import * as plugins from "./smartnginx.plugins";
|
||||||
import * as paths from "./smartnginx.paths";
|
import * as paths from "./smartnginx.paths";
|
||||||
import { NginxConfig } from "./smartnginx.classes.nginxconfig";
|
import { NginxConfig } from "./smartnginx.classes.nginxconfig";
|
||||||
import { NginxZone } from "./smartnginx.classes.nginxzone";
|
import { NginxHost } from "./smartnginx.classes.nginxhost";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* manages a nginxprocess for an NginxConfig
|
||||||
|
*/
|
||||||
export class NginxProcess {
|
export class NginxProcess {
|
||||||
started: boolean = false;
|
started: boolean = false;
|
||||||
nginxConfig:NginxConfig;
|
nginxConfig:NginxConfig;
|
||||||
@ -37,7 +40,7 @@ export class NginxProcess {
|
|||||||
reloadConfig(){
|
reloadConfig(){
|
||||||
let done = plugins.q.defer();
|
let done = plugins.q.defer();
|
||||||
if(this.started == false){
|
if(this.started == false){
|
||||||
this.start()
|
this.start();
|
||||||
} else {
|
} else {
|
||||||
plugins.shelljs.exec("nginx -s reload");
|
plugins.shelljs.exec("nginx -s reload");
|
||||||
};
|
};
|
||||||
|
@ -1,34 +0,0 @@
|
|||||||
import * as plugins from "./smartnginx.plugins";
|
|
||||||
import * as paths from "./smartnginx.paths";
|
|
||||||
import * as snippets from "./smartnginx.snippets"
|
|
||||||
export enum zoneTypes {
|
|
||||||
reverseProxy,
|
|
||||||
static
|
|
||||||
}
|
|
||||||
|
|
||||||
export class NginxZone {
|
|
||||||
zoneName: string; // the zone name e.g. domain name
|
|
||||||
type: zoneTypes;
|
|
||||||
destination: string;
|
|
||||||
configString: string; // the actual zone config file as string
|
|
||||||
constructor(optionsArg: {
|
|
||||||
zoneName: string,
|
|
||||||
type: zoneTypes,
|
|
||||||
destination: string
|
|
||||||
}) {
|
|
||||||
this.zoneName = optionsArg.zoneName;
|
|
||||||
this.type = optionsArg.type;
|
|
||||||
this.destination = optionsArg.destination;
|
|
||||||
this.configString = snippets.getZoneConfigString(optionsArg.zoneName, optionsArg.destination);
|
|
||||||
};
|
|
||||||
deploy(certInstanceArg: plugins.cert.Cert) {
|
|
||||||
let done = plugins.q.defer();
|
|
||||||
let filePath = plugins.path.join(paths.nginxZoneBase, this.zoneName + ".conf");
|
|
||||||
// writeConfig
|
|
||||||
plugins.smartfile.memory.toFsSync(this.configString, filePath);
|
|
||||||
// get cert
|
|
||||||
certInstanceArg.getDomainCert(this.zoneName)
|
|
||||||
.then(done.resolve);
|
|
||||||
return done.promise;
|
|
||||||
};
|
|
||||||
};
|
|
@ -3,7 +3,7 @@ import * as plugins from "./smartnginx.plugins"
|
|||||||
// directories
|
// directories
|
||||||
export let packageBase = plugins.path.join(__dirname,"../");
|
export let packageBase = plugins.path.join(__dirname,"../");
|
||||||
export let nginxConfigBase = plugins.path.join(packageBase,"nginxconfig");
|
export let nginxConfigBase = plugins.path.join(packageBase,"nginxconfig");
|
||||||
export let nginxZoneBase = plugins.path.join(nginxConfigBase,"zones");
|
export let nginxHostFileBase = plugins.path.join(nginxConfigBase,"hosts");
|
||||||
export let nginxCertBase = plugins.path.join(nginxConfigBase,"cert");
|
export let nginxCertBase = plugins.path.join(nginxConfigBase,"cert");
|
||||||
|
|
||||||
// files
|
// files
|
||||||
|
@ -71,26 +71,26 @@ export let getBaseConfigString = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export let getZoneConfigString = (zoneNameArg:string,destinationIpArg:string) => {
|
export let getHostConfigString = (hostNameArg:string,destinationIpArg:string) => {
|
||||||
let zoneConfig = plugins.smartstring.indent.normalize(`
|
let hostConfig = plugins.smartstring.indent.normalize(`
|
||||||
upstream ${zoneNameArg} {
|
upstream ${hostNameArg} {
|
||||||
server ${destinationIpArg};
|
server ${destinationIpArg};
|
||||||
}
|
}
|
||||||
|
|
||||||
server {
|
server {
|
||||||
listen *:80 ;
|
listen *:80 ;
|
||||||
server_name ${zoneNameArg};
|
server_name ${hostNameArg};
|
||||||
rewrite ^ https://${zoneNameArg}$request_uri? permanent;
|
rewrite ^ https://${hostNameArg}$request_uri? permanent;
|
||||||
}
|
}
|
||||||
|
|
||||||
server {
|
server {
|
||||||
listen *:443 ssl;
|
listen *:443 ssl;
|
||||||
server_name ${zoneNameArg};
|
server_name ${hostNameArg};
|
||||||
ssl_certificate /LE_CERTS/${zoneNameArg}/fullchain.pem;
|
ssl_certificate /LE_CERTS/${hostNameArg}/fullchain.pem;
|
||||||
ssl_certificate_key /LE_CERTS/${zoneNameArg}/privkey.pem;
|
ssl_certificate_key /LE_CERTS/${hostNameArg}/privkey.pem;
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
proxy_pass http://${zoneNameArg};
|
proxy_pass http://${hostNameArg};
|
||||||
include /etc/nginx/proxy_params;
|
include /etc/nginx/proxy_params;
|
||||||
}
|
}
|
||||||
location ~ /\.git {
|
location ~ /\.git {
|
||||||
@ -98,6 +98,6 @@ export let getZoneConfigString = (zoneNameArg:string,destinationIpArg:string) =>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
`);
|
`);
|
||||||
return zoneConfig;
|
return hostConfig;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user