Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
9864dcc56a | |||
bd6c76cbfd | |||
c50f1f73dd | |||
a15f05cedb | |||
8ebde757b2 | |||
48a1429332 |
20
README.md
20
README.md
@ -1,2 +1,20 @@
|
||||
# smartnginx
|
||||
control nginx from node
|
||||
control nginx from node, TypeScript ready
|
||||
|
||||
## Status
|
||||
[](https://gitlab.com/pushrocks/smartnginx/commits/master)
|
||||
|
||||
## Usage
|
||||
We recommend the use of TypeScript! :)
|
||||
|
||||
```typescript
|
||||
import * as smartnginx from "smartnginx";
|
||||
myNginxConfig = new smartnginx.NginxConfig();
|
||||
myNginxZone = new smartnginx.NginxZone({
|
||||
zoneName:"some.example.com",
|
||||
type:"reverseProxy",
|
||||
destination:"192.192.192.192" // some destination IP
|
||||
});
|
||||
myNginxConfig.addZone(myNginxZone); // adds the zone to the config
|
||||
myNginxConfig.deploy(); // deploys the referenced NginxConfig and restarts nginx
|
||||
```
|
5
dist/index.d.ts
vendored
5
dist/index.d.ts
vendored
@ -1 +1,4 @@
|
||||
export { NginxConfig, NginxZone } from "./smartnginx.classes.nginxconfig";
|
||||
import * as CommandModule from "./smartnginx.command";
|
||||
export { NginxConfig } from "./smartnginx.classes.nginxconfig";
|
||||
export { NginxZone, zoneTypes } from "./smartnginx.classes.nginxzone";
|
||||
export declare let command: typeof CommandModule;
|
||||
|
9
dist/index.js
vendored
9
dist/index.js
vendored
@ -1,6 +1,11 @@
|
||||
"use strict";
|
||||
var CommandModule = require("./smartnginx.command");
|
||||
// classes
|
||||
var smartnginx_classes_nginxconfig_1 = require("./smartnginx.classes.nginxconfig");
|
||||
exports.NginxConfig = smartnginx_classes_nginxconfig_1.NginxConfig;
|
||||
exports.NginxZone = smartnginx_classes_nginxconfig_1.NginxZone;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBRUEsVUFBVTtBQUNWLCtDQUFvQyxrQ0FBa0MsQ0FBQztBQUEvRCxtRUFBVztBQUFDLCtEQUFtRCJ9
|
||||
var smartnginx_classes_nginxzone_1 = require("./smartnginx.classes.nginxzone");
|
||||
exports.NginxZone = smartnginx_classes_nginxzone_1.NginxZone;
|
||||
exports.zoneTypes = smartnginx_classes_nginxzone_1.zoneTypes;
|
||||
// exports
|
||||
exports.command = CommandModule;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQ0EsSUFBWSxhQUFhLFdBQU0sc0JBQXNCLENBQUMsQ0FBQTtBQUV0RCxVQUFVO0FBQ1YsK0NBQTBCLGtDQUFrQyxDQUFDO0FBQXJELG1FQUFxRDtBQUM3RCw2Q0FBa0MsZ0NBQWdDLENBQUM7QUFBM0QsNkRBQVM7QUFBQyw2REFBaUQ7QUFFbkUsVUFBVTtBQUNDLGVBQU8sR0FBRyxhQUFhLENBQUMifQ==
|
16
dist/smartnginx.classes.nginxconfig.d.ts
vendored
16
dist/smartnginx.classes.nginxconfig.d.ts
vendored
@ -1,20 +1,10 @@
|
||||
export declare enum ZoneTypes {
|
||||
}
|
||||
import { NginxZone } from "./smartnginx.classes.nginxzone";
|
||||
export declare class NginxConfig {
|
||||
zones: NginxZone[];
|
||||
isDeployed: boolean;
|
||||
constructor();
|
||||
addZone(zoneArg: NginxZone): void;
|
||||
listZones(): NginxZone[];
|
||||
removeZones(zoneArg: NginxZone): void;
|
||||
deploy(): void;
|
||||
nginxStart(): void;
|
||||
nginxStop(): void;
|
||||
}
|
||||
export declare class NginxZone {
|
||||
domain: any;
|
||||
constructor(optionsArg: {
|
||||
zoneName: string;
|
||||
type: ZoneTypes;
|
||||
destination: string;
|
||||
});
|
||||
deploy(nginxRestartArg?: boolean): void;
|
||||
}
|
||||
|
40
dist/smartnginx.classes.nginxconfig.js
vendored
40
dist/smartnginx.classes.nginxconfig.js
vendored
@ -1,9 +1,12 @@
|
||||
"use strict";
|
||||
(function (ZoneTypes) {
|
||||
})(exports.ZoneTypes || (exports.ZoneTypes = {}));
|
||||
var ZoneTypes = exports.ZoneTypes;
|
||||
var plugins = require("./smartnginx.plugins");
|
||||
var paths = require("./smartnginx.paths");
|
||||
var command = require("./smartnginx.command");
|
||||
var snippets = require("./smartnginx.snippets");
|
||||
var allConfigs = [];
|
||||
var NginxConfig = (function () {
|
||||
function NginxConfig() {
|
||||
this.isDeployed = false;
|
||||
}
|
||||
;
|
||||
// interact with Zones
|
||||
@ -16,24 +19,29 @@ var NginxConfig = (function () {
|
||||
NginxConfig.prototype.removeZones = function (zoneArg) {
|
||||
};
|
||||
// handle deployment of zones
|
||||
NginxConfig.prototype.deploy = function () {
|
||||
};
|
||||
NginxConfig.prototype.deploy = function (nginxRestartArg) {
|
||||
if (nginxRestartArg === void 0) { nginxRestartArg = false; }
|
||||
plugins.smartfile.fs.remove(paths.nginxConfigBase);
|
||||
plugins.smartfile.fs.ensureDir(paths.nginxConfigBase);
|
||||
for (var _i = 0, allConfigs_1 = allConfigs; _i < allConfigs_1.length; _i++) {
|
||||
var config = allConfigs_1[_i];
|
||||
config.isDeployed = false;
|
||||
}
|
||||
;
|
||||
NginxConfig.prototype.nginxStart = function () {
|
||||
};
|
||||
this.isDeployed = true;
|
||||
for (var _a = 0, _b = this.zones; _a < _b.length; _a++) {
|
||||
var zone = _b[_a];
|
||||
zone.deploy();
|
||||
}
|
||||
;
|
||||
NginxConfig.prototype.nginxStop = function () {
|
||||
plugins.smartfile.memory.toFsSync(snippets.getBaseConfigString(), plugins.path.join(paths.nginxConfigBase, "nginx.conf"));
|
||||
if (nginxRestartArg) {
|
||||
command.restart(this);
|
||||
}
|
||||
};
|
||||
;
|
||||
return NginxConfig;
|
||||
}());
|
||||
exports.NginxConfig = NginxConfig;
|
||||
;
|
||||
var NginxZone = (function () {
|
||||
function NginxZone(optionsArg) {
|
||||
}
|
||||
return NginxZone;
|
||||
}());
|
||||
exports.NginxZone = NginxZone;
|
||||
var mynginx = new NginxConfig();
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRuZ2lueC5jbGFzc2VzLm5naW54Y29uZmlnLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRuZ2lueC5jbGFzc2VzLm5naW54Y29uZmlnLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFFQSxXQUFZLFNBQVM7QUFFckIsQ0FBQyxFQUZXLGlCQUFTLEtBQVQsaUJBQVMsUUFFcEI7QUFGRCxJQUFZLFNBQVMsR0FBVCxpQkFFWCxDQUFBO0FBRUQ7SUFFSTtJQUVBLENBQUM7O0lBRUQsc0JBQXNCO0lBQ3RCLDZCQUFPLEdBQVAsVUFBUSxPQUFpQjtJQUV6QixDQUFDO0lBQ0QsK0JBQVMsR0FBVDtRQUNJLE1BQU0sQ0FBQyxJQUFJLENBQUMsS0FBSyxDQUFDO0lBQ3RCLENBQUM7O0lBQ0QsaUNBQVcsR0FBWCxVQUFZLE9BQWlCO0lBRTdCLENBQUM7SUFFRCw2QkFBNkI7SUFDN0IsNEJBQU0sR0FBTjtJQUVBLENBQUM7O0lBQ0QsZ0NBQVUsR0FBVjtJQUVBLENBQUM7O0lBQ0QsK0JBQVMsR0FBVDtJQUVBLENBQUM7O0lBQ0wsa0JBQUM7QUFBRCxDQUFDLEFBM0JELElBMkJDO0FBM0JZLG1CQUFXLGNBMkJ2QixDQUFBO0FBQUEsQ0FBQztBQUVGO0lBRUksbUJBQVksVUFJWDtJQUVELENBQUM7SUFDTCxnQkFBQztBQUFELENBQUMsQUFURCxJQVNDO0FBVFksaUJBQVMsWUFTckIsQ0FBQTtBQUVELElBQUksT0FBTyxHQUFHLElBQUksV0FBVyxFQUFFLENBQUMifQ==
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRuZ2lueC5jbGFzc2VzLm5naW54Y29uZmlnLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRuZ2lueC5jbGFzc2VzLm5naW54Y29uZmlnLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxJQUFZLE9BQU8sV0FBTSxzQkFBc0IsQ0FBQyxDQUFBO0FBQ2hELElBQVksS0FBSyxXQUFNLG9CQUFvQixDQUFDLENBQUE7QUFDNUMsSUFBWSxPQUFPLFdBQU0sc0JBQXNCLENBQUMsQ0FBQTtBQUNoRCxJQUFZLFFBQVEsV0FBTSx1QkFDMUIsQ0FBQyxDQURnRDtBQUVqRCxJQUFJLFVBQVUsR0FBaUIsRUFBRSxDQUFDO0FBRWxDO0lBR0k7UUFEQSxlQUFVLEdBQVcsS0FBSyxDQUFDO0lBRzNCLENBQUM7O0lBRUQsc0JBQXNCO0lBQ3RCLDZCQUFPLEdBQVAsVUFBUSxPQUFpQjtJQUV6QixDQUFDO0lBQ0QsK0JBQVMsR0FBVDtRQUNJLE1BQU0sQ0FBQyxJQUFJLENBQUMsS0FBSyxDQUFDO0lBQ3RCLENBQUM7O0lBQ0QsaUNBQVcsR0FBWCxVQUFZLE9BQWlCO0lBRTdCLENBQUM7SUFFRCw2QkFBNkI7SUFDN0IsNEJBQU0sR0FBTixVQUFPLGVBQStCO1FBQS9CLCtCQUErQixHQUEvQix1QkFBK0I7UUFDbEMsT0FBTyxDQUFDLFNBQVMsQ0FBQyxFQUFFLENBQUMsTUFBTSxDQUFDLEtBQUssQ0FBQyxlQUFlLENBQUMsQ0FBQztRQUNuRCxPQUFPLENBQUMsU0FBUyxDQUFDLEVBQUUsQ0FBQyxTQUFTLENBQUMsS0FBSyxDQUFDLGVBQWUsQ0FBQyxDQUFDO1FBQ3RELEdBQUcsQ0FBQSxDQUFlLFVBQVUsRUFBVix5QkFBVSxFQUFWLHdCQUFVLEVBQVYsSUFBVSxDQUFDO1lBQXpCLElBQUksTUFBTSxtQkFBQTtZQUNWLE1BQU0sQ0FBQyxVQUFVLEdBQUcsS0FBSyxDQUFDO1NBQzdCO1FBQUEsQ0FBQztRQUNGLElBQUksQ0FBQyxVQUFVLEdBQUcsSUFBSSxDQUFDO1FBQ3ZCLEdBQUcsQ0FBQSxDQUFhLFVBQVUsRUFBVixLQUFBLElBQUksQ0FBQyxLQUFLLEVBQVYsY0FBVSxFQUFWLElBQVUsQ0FBQztZQUF2QixJQUFJLElBQUksU0FBQTtZQUNSLElBQUksQ0FBQyxNQUFNLEVBQUUsQ0FBQztTQUNqQjtRQUFBLENBQUM7UUFDRixPQUFPLENBQUMsU0FBUyxDQUFDLE1BQU0sQ0FBQyxRQUFRLENBQzdCLFFBQVEsQ0FBQyxtQkFBbUIsRUFBRSxFQUM5QixPQUFPLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxLQUFLLENBQUMsZUFBZSxFQUFDLFlBQVksQ0FBQyxDQUN4RCxDQUFDO1FBQ0YsRUFBRSxDQUFBLENBQUMsZUFBZSxDQUFDLENBQUEsQ0FBQztZQUNoQixPQUFPLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxDQUFDO1FBQzFCLENBQUM7SUFDTCxDQUFDOztJQUVMLGtCQUFDO0FBQUQsQ0FBQyxBQXRDRCxJQXNDQztBQXRDWSxtQkFBVyxjQXNDdkIsQ0FBQTtBQUFBLENBQUMifQ==
|
14
dist/smartnginx.classes.nginxzone.d.ts
vendored
Normal file
14
dist/smartnginx.classes.nginxzone.d.ts
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
export declare enum zoneTypes {
|
||||
reverseProxy = 0,
|
||||
static = 1,
|
||||
}
|
||||
export declare class NginxZone {
|
||||
zoneName: string;
|
||||
configString: string;
|
||||
constructor(optionsArg: {
|
||||
zoneName: string;
|
||||
type: zoneTypes;
|
||||
destination: string;
|
||||
});
|
||||
deploy(): void;
|
||||
}
|
24
dist/smartnginx.classes.nginxzone.js
vendored
Normal file
24
dist/smartnginx.classes.nginxzone.js
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
"use strict";
|
||||
var plugins = require("./smartnginx.plugins");
|
||||
var paths = require("./smartnginx.paths");
|
||||
var snippets = require("./smartnginx.snippets");
|
||||
(function (zoneTypes) {
|
||||
zoneTypes[zoneTypes["reverseProxy"] = 0] = "reverseProxy";
|
||||
zoneTypes[zoneTypes["static"] = 1] = "static";
|
||||
})(exports.zoneTypes || (exports.zoneTypes = {}));
|
||||
var zoneTypes = exports.zoneTypes;
|
||||
var NginxZone = (function () {
|
||||
function NginxZone(optionsArg) {
|
||||
this.configString = snippets.getZoneConfigString(optionsArg.zoneName, optionsArg.destination);
|
||||
}
|
||||
;
|
||||
NginxZone.prototype.deploy = function () {
|
||||
var filePath = plugins.path.join(paths.nginxZoneBase, this.zoneName + ".conf");
|
||||
plugins.smartfile.memory.toFsSync(this.configString, filePath);
|
||||
};
|
||||
;
|
||||
return NginxZone;
|
||||
}());
|
||||
exports.NginxZone = NginxZone;
|
||||
;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRuZ2lueC5jbGFzc2VzLm5naW54em9uZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0bmdpbnguY2xhc3Nlcy5uZ2lueHpvbmUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLElBQVksT0FBTyxXQUFNLHNCQUFzQixDQUFDLENBQUE7QUFDaEQsSUFBWSxLQUFLLFdBQU0sb0JBQW9CLENBQUMsQ0FBQTtBQUU1QyxJQUFZLFFBQVEsV0FBTSx1QkFDMUIsQ0FBQyxDQURnRDtBQUNqRCxXQUFZLFNBQVM7SUFDZCx5REFBWSxDQUFBO0lBQ1osNkNBQU0sQ0FBQTtBQUNiLENBQUMsRUFIVyxpQkFBUyxLQUFULGlCQUFTLFFBR3BCO0FBSEQsSUFBWSxTQUFTLEdBQVQsaUJBR1gsQ0FBQTtBQUVEO0lBR0ksbUJBQVksVUFJWDtRQUNHLElBQUksQ0FBQyxZQUFZLEdBQUcsUUFBUSxDQUFDLG1CQUFtQixDQUFDLFVBQVUsQ0FBQyxRQUFRLEVBQUMsVUFBVSxDQUFDLFdBQVcsQ0FBQyxDQUFDO0lBQ2pHLENBQUM7O0lBQ0QsMEJBQU0sR0FBTjtRQUNJLElBQUksUUFBUSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLEtBQUssQ0FBQyxhQUFhLEVBQUMsSUFBSSxDQUFDLFFBQVEsR0FBRyxPQUFPLENBQUMsQ0FBQztRQUM5RSxPQUFPLENBQUMsU0FBUyxDQUFDLE1BQU0sQ0FBQyxRQUFRLENBQUMsSUFBSSxDQUFDLFlBQVksRUFBQyxRQUFRLENBQUMsQ0FBQztJQUNsRSxDQUFDOztJQUNMLGdCQUFDO0FBQUQsQ0FBQyxBQWRELElBY0M7QUFkWSxpQkFBUyxZQWNyQixDQUFBO0FBQUEsQ0FBQyJ9
|
14
dist/smartnginx.command.d.ts
vendored
Normal file
14
dist/smartnginx.command.d.ts
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
import { NginxConfig } from "./smartnginx.classes.nginxconfig";
|
||||
/**
|
||||
* starts nginx
|
||||
*/
|
||||
export declare let start: (configArg: NginxConfig) => void;
|
||||
export declare let restart: (configArg: NginxConfig) => void;
|
||||
/**
|
||||
* stops nginx
|
||||
*/
|
||||
export declare let stop: () => void;
|
||||
/**
|
||||
* checks if nginx is in path
|
||||
*/
|
||||
export declare let check: () => boolean;
|
22
dist/smartnginx.command.js
vendored
Normal file
22
dist/smartnginx.command.js
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
"use strict";
|
||||
/**
|
||||
* starts nginx
|
||||
*/
|
||||
exports.start = function (configArg) {
|
||||
};
|
||||
exports.restart = function (configArg) {
|
||||
exports.stop();
|
||||
exports.start(configArg);
|
||||
};
|
||||
/**
|
||||
* stops nginx
|
||||
*/
|
||||
exports.stop = function () {
|
||||
};
|
||||
/**
|
||||
* checks if nginx is in path
|
||||
*/
|
||||
exports.check = function () {
|
||||
return;
|
||||
};
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRuZ2lueC5jb21tYW5kLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRuZ2lueC5jb21tYW5kLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFJQTs7R0FFRztBQUNRLGFBQUssR0FBRyxVQUFDLFNBQXFCO0FBRXpDLENBQUMsQ0FBQztBQUVTLGVBQU8sR0FBRyxVQUFDLFNBQXFCO0lBQ3ZDLFlBQUksRUFBRSxDQUFDO0lBQ1AsYUFBSyxDQUFDLFNBQVMsQ0FBQyxDQUFDO0FBQ3JCLENBQUMsQ0FBQTtBQUVEOztHQUVHO0FBQ1EsWUFBSSxHQUFHO0FBRWxCLENBQUMsQ0FBQztBQUVGOztHQUVHO0FBQ1EsYUFBSyxHQUFHO0lBQ2YsTUFBTSxDQUFDO0FBQ1gsQ0FBQyxDQUFDIn0=
|
3
dist/smartnginx.paths.d.ts
vendored
Normal file
3
dist/smartnginx.paths.d.ts
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
export declare let packageBase: string;
|
||||
export declare let nginxConfigBase: string;
|
||||
export declare let nginxZoneBase: string;
|
6
dist/smartnginx.paths.js
vendored
Normal file
6
dist/smartnginx.paths.js
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
"use strict";
|
||||
var plugins = require("./smartnginx.plugins");
|
||||
exports.packageBase = plugins.path.join(__dirname, "../");
|
||||
exports.nginxConfigBase = plugins.path.join(exports.packageBase, "nginxconfig/");
|
||||
exports.nginxZoneBase = plugins.path.join(exports.nginxConfigBase, "zones");
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRuZ2lueC5wYXRocy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0bmdpbngucGF0aHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLElBQVksT0FBTyxXQUFNLHNCQUV6QixDQUFDLENBRjhDO0FBRXBDLG1CQUFXLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsU0FBUyxFQUFDLEtBQUssQ0FBQyxDQUFDO0FBQ2pELHVCQUFlLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsbUJBQVcsRUFBQyxjQUFjLENBQUMsQ0FBQztBQUNoRSxxQkFBYSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLHVCQUFlLEVBQUMsT0FBTyxDQUFDLENBQUMifQ==
|
4
dist/smartnginx.plugins.d.ts
vendored
4
dist/smartnginx.plugins.d.ts
vendored
@ -1,3 +1,7 @@
|
||||
import "typings-global";
|
||||
export import cert = require("cert");
|
||||
export import path = require("path");
|
||||
export import q = require("q");
|
||||
export declare let shelljs: any;
|
||||
export import smartfile = require("smartfile");
|
||||
export import smartstring = require("smartstring");
|
||||
|
6
dist/smartnginx.plugins.js
vendored
6
dist/smartnginx.plugins.js
vendored
@ -1,5 +1,9 @@
|
||||
"use strict";
|
||||
require("typings-global");
|
||||
exports.cert = require("cert");
|
||||
exports.path = require("path");
|
||||
exports.q = require("q");
|
||||
exports.shelljs = require("shelljs");
|
||||
exports.smartfile = require("smartfile");
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRuZ2lueC5wbHVnaW5zLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRuZ2lueC5wbHVnaW5zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBYyxZQUFJLFdBQVcsTUFBTSxDQUFDLENBQUM7QUFDdkIsU0FBQyxXQUFXLEdBQUcsQ0FBQyxDQUFDO0FBQ2pCLGlCQUFTLFdBQVcsV0FBVyxDQUFDLENBQUMifQ==
|
||||
exports.smartstring = require("smartstring");
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRuZ2lueC5wbHVnaW5zLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRuZ2lueC5wbHVnaW5zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUFnQixDQUFDLENBQUE7QUFDVixZQUFJLFdBQVcsTUFBTSxDQUFDLENBQUM7QUFDdkIsWUFBSSxXQUFXLE1BQU0sQ0FBQyxDQUFDO0FBQ3ZCLFNBQUMsV0FBVyxHQUFHLENBQUMsQ0FBQztBQUNwQixlQUFPLEdBQUcsT0FBTyxDQUFDLFNBQVMsQ0FBQyxDQUFDO0FBQzFCLGlCQUFTLFdBQVcsV0FBVyxDQUFDLENBQUM7QUFDakMsbUJBQVcsV0FBVyxhQUFhLENBQUMsQ0FBQyJ9
|
2
dist/smartnginx.snippets.d.ts
vendored
Normal file
2
dist/smartnginx.snippets.d.ts
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
export declare let getBaseConfigString: () => void;
|
||||
export declare let getZoneConfigString: (zoneNameArg: string, destinationIpArg: string) => string;
|
10
dist/smartnginx.snippets.js
vendored
Normal file
10
dist/smartnginx.snippets.js
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
"use strict";
|
||||
var plugins = require("./smartnginx.plugins");
|
||||
exports.getBaseConfigString = function () {
|
||||
var baseConfig = plugins.smartstring.indent.normalize("\n\t\tuser www-data;\n\t\tworker_processes auto;\n\t\tpid /run/nginx.pid;\n\n\t\tevents {\n\t\t\tworker_connections 768;\n\t\t\t# multi_accept on;\n\t\t}\n\n\t\thttp {\n\t\t\tserver_names_hash_bucket_size 128;\n\n\t\t\t##\n\t\t\t# Basic Settings\n\t\t\t##\n\n\t\t\tsendfile on;\n\t\t\ttcp_nopush on;\n\t\t\ttcp_nodelay on;\n\t\t\tkeepalive_timeout 65;\n\t\t\ttypes_hash_max_size 2048;\n\t\t\t# server_tokens off;\n\n\t\t\t# server_names_hash_bucket_size 64;\n\t\t\t# server_name_in_redirect off;\n\n\t\t\tinclude /etc/nginx/mime.types;\n\t\t\tdefault_type application/octet-stream;\n\n\t\t\t##\n\t\t\t# SSL Settings\n\t\t\t##\n\n\t\t\tssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE\n\t\t\tssl_prefer_server_ciphers on;\n\n\t\t\t##\n\t\t\t# Logging Settings\n\t\t\t##\n\n\t\t\taccess_log /var/log/nginx/access.log;\n\t\t\terror_log /var/log/nginx/error.log;\n\n\t\t\t##\n\t\t\t# Gzip Settings\n\t\t\t##\n\n\t\t\tgzip on;\n\t\t\tgzip_disable \"msie6\";\n\n\t\t\t# gzip_vary on;\n\t\t\t# gzip_proxied any;\n\t\t\t# gzip_comp_level 6;\n\t\t\t# gzip_buffers 16 8k;\n\t\t\t# gzip_http_version 1.1;\n\t\t\t# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;\n\n\t\t\t##\n\t\t\t# Virtual Host Configs\n\t\t\t##\n\n\t\t\tinclude /etc/nginx/conf.d/*.conf;\n\t\t\tinclude /etc/nginx/sites-enabled/*;\n\t\t}\n\t\tdaemon off;\n\t");
|
||||
};
|
||||
exports.getZoneConfigString = function (zoneNameArg, destinationIpArg) {
|
||||
var zoneConfig = plugins.smartstring.indent.normalize("\n\t\tupstream " + zoneNameArg + " {\n\t\t\tserver " + destinationIpArg + ";\n\t\t}\n\n\t\tserver {\n\t\t\tlisten *:80 ;\n\t\t\tserver_name " + zoneNameArg + ";\n\t\t\trewrite ^ https://" + zoneNameArg + "$request_uri? permanent;\n\t\t}\n\n\t\tserver {\n\t\t\tlisten *:443 ssl;\n\t\t\tserver_name " + zoneNameArg + ";\n\t\t\tssl_certificate /LE_CERTS/" + zoneNameArg + "/fullchain.pem;\n\t\t\tssl_certificate_key /LE_CERTS/" + zoneNameArg + "/privkey.pem;\n\n\t\t\tlocation / {\n\t\t\t\tproxy_pass http://" + zoneNameArg + ";\n\t\t\t\tinclude /etc/nginx/proxy_params;\n\t\t\t}\n\t\t\tlocation ~ /.git {\n\t\t\t\tdeny all;\n\t\t\t}\n\t\t}\n\t");
|
||||
return zoneConfig;
|
||||
};
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRuZ2lueC5zbmlwcGV0cy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0bmdpbnguc25pcHBldHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLElBQVksT0FBTyxXQUFNLHNCQUFzQixDQUFDLENBQUE7QUFDckMsMkJBQW1CLEdBQUc7SUFDaEMsSUFBSSxVQUFVLEdBQUcsT0FBTyxDQUFDLFdBQVcsQ0FBQyxNQUFNLENBQUMsU0FBUyxDQUFDLDY0Q0FrRXJELENBQUMsQ0FBQztBQUNKLENBQUMsQ0FBQTtBQUdVLDJCQUFtQixHQUFHLFVBQUMsV0FBa0IsRUFBQyxnQkFBdUI7SUFDM0UsSUFBSSxVQUFVLEdBQUcsT0FBTyxDQUFDLFdBQVcsQ0FBQyxNQUFNLENBQUMsU0FBUyxDQUFDLG9CQUMxQyxXQUFXLHlCQUNaLGdCQUFnQix5RUFLWCxXQUFXLDBDQUNFLFdBQVcsb0dBS3hCLFdBQVcsMkNBQ0csV0FBVyw2REFDUCxXQUFXLHVFQUd0QixXQUFXLDBIQU9qQyxDQUFDLENBQUM7SUFDSCxNQUFNLENBQUMsVUFBVSxDQUFDO0FBQ25CLENBQUMsQ0FBQyJ9
|
65
nginxconfig/nginx.conf
Normal file
65
nginxconfig/nginx.conf
Normal file
@ -0,0 +1,65 @@
|
||||
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 /etc/nginx/conf.d/*.conf;
|
||||
include /etc/nginx/sites-enabled/*;
|
||||
}
|
||||
daemon off;
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "smartnginx",
|
||||
"version": "0.0.1",
|
||||
"description": "control nginx from node",
|
||||
"version": "0.0.3",
|
||||
"description": "control nginx from node, TypeScript ready",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"scripts": {
|
||||
@ -24,7 +24,9 @@
|
||||
"@types/q": "0.0.25-alpha",
|
||||
"cert": "0.0.13",
|
||||
"q": "^1.4.1",
|
||||
"smartfile": "^4.0.10"
|
||||
"shelljs": "^0.7.0",
|
||||
"smartfile": "^4.0.10",
|
||||
"smartstring": "^2.0.14"
|
||||
},
|
||||
"devDependencies": {
|
||||
"npmts-g": "^5.2.6",
|
||||
|
25
test/test.js
25
test/test.js
@ -1,4 +1,27 @@
|
||||
"use strict";
|
||||
require("typings-test");
|
||||
require("should");
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sY0FBYyxDQUFDLENBQUE7QUFDdEIsUUFBTyxRQUFRLENBQUMsQ0FBQSJ9
|
||||
var smartnginx = require("../dist/index");
|
||||
describe("smartnginx", function () {
|
||||
var testNginxConfig;
|
||||
var testNginxZone01;
|
||||
var testNginxZone02;
|
||||
describe("NginxZone", function () {
|
||||
it("\"new NginxZone()\" should produce an instance of NginxConfig", function () {
|
||||
testNginxZone01 = new smartnginx.NginxZone({
|
||||
zoneName: "test1.bleu.de",
|
||||
type: smartnginx.zoneTypes.reverseProxy,
|
||||
destination: "192.192.192.192"
|
||||
});
|
||||
testNginxZone01.should.be.instanceof(smartnginx.NginxZone);
|
||||
console.log(testNginxZone01.configString);
|
||||
});
|
||||
});
|
||||
describe("NginxConfig", function () {
|
||||
it("\"new NginxConfig()\" should produce an instance of NginxConfig", function () {
|
||||
testNginxConfig = new smartnginx.NginxConfig();
|
||||
testNginxConfig.should.be.instanceof(smartnginx.NginxConfig);
|
||||
});
|
||||
});
|
||||
});
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sY0FBYyxDQUFDLENBQUE7QUFDdEIsUUFBTyxRQUFRLENBQUMsQ0FBQTtBQUNoQixJQUFZLFVBQVUsV0FBTSxlQUFlLENBQUMsQ0FBQTtBQUU1QyxRQUFRLENBQUMsWUFBWSxFQUFDO0lBQ2xCLElBQUksZUFBc0MsQ0FBQztJQUMzQyxJQUFJLGVBQW9DLENBQUM7SUFDekMsSUFBSSxlQUFvQyxDQUFDO0lBQ3pDLFFBQVEsQ0FBQyxXQUFXLEVBQUM7UUFDakIsRUFBRSxDQUFDLCtEQUE2RCxFQUFDO1lBQzdELGVBQWUsR0FBRyxJQUFJLFVBQVUsQ0FBQyxTQUFTLENBQUM7Z0JBQ3ZDLFFBQVEsRUFBQyxlQUFlO2dCQUN4QixJQUFJLEVBQUMsVUFBVSxDQUFDLFNBQVMsQ0FBQyxZQUFZO2dCQUN0QyxXQUFXLEVBQUMsaUJBQWlCO2FBQ2hDLENBQUMsQ0FBQztZQUNILGVBQWUsQ0FBQyxNQUFNLENBQUMsRUFBRSxDQUFDLFVBQVUsQ0FBQyxVQUFVLENBQUMsU0FBUyxDQUFDLENBQUM7WUFDM0QsT0FBTyxDQUFDLEdBQUcsQ0FBQyxlQUFlLENBQUMsWUFBWSxDQUFDLENBQUM7UUFDOUMsQ0FBQyxDQUFDLENBQUM7SUFDUCxDQUFDLENBQUMsQ0FBQztJQUNILFFBQVEsQ0FBQyxhQUFhLEVBQUM7UUFDbkIsRUFBRSxDQUFDLGlFQUErRCxFQUFDO1lBQy9ELGVBQWUsR0FBRyxJQUFJLFVBQVUsQ0FBQyxXQUFXLEVBQUUsQ0FBQztZQUMvQyxlQUFlLENBQUMsTUFBTSxDQUFDLEVBQUUsQ0FBQyxVQUFVLENBQUMsVUFBVSxDQUFDLFdBQVcsQ0FBQyxDQUFDO1FBQ2pFLENBQUMsQ0FBQyxDQUFDO0lBQ1AsQ0FBQyxDQUFDLENBQUM7QUFDUCxDQUFDLENBQUMsQ0FBQyJ9
|
25
test/test.ts
25
test/test.ts
@ -1,3 +1,26 @@
|
||||
import "typings-test";
|
||||
import "should";
|
||||
import smartnginx from "../dist/index"
|
||||
import * as smartnginx from "../dist/index";
|
||||
|
||||
describe("smartnginx",function(){
|
||||
let testNginxConfig:smartnginx.NginxConfig;
|
||||
let testNginxZone01:smartnginx.NginxZone;
|
||||
let testNginxZone02:smartnginx.NginxZone;
|
||||
describe("NginxZone",function(){
|
||||
it(`"new NginxZone()" should produce an instance of NginxConfig`,function(){
|
||||
testNginxZone01 = new smartnginx.NginxZone({
|
||||
zoneName:"test1.bleu.de",
|
||||
type:smartnginx.zoneTypes.reverseProxy,
|
||||
destination:"192.192.192.192"
|
||||
});
|
||||
testNginxZone01.should.be.instanceof(smartnginx.NginxZone);
|
||||
console.log(testNginxZone01.configString);
|
||||
});
|
||||
});
|
||||
describe("NginxConfig",function(){
|
||||
it(`"new NginxConfig()" should produce an instance of NginxConfig`,function(){
|
||||
testNginxConfig = new smartnginx.NginxConfig();
|
||||
testNginxConfig.should.be.instanceof(smartnginx.NginxConfig);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1,4 +1,9 @@
|
||||
import * as plugins from "./smartnginx.plugins";
|
||||
import * as CommandModule from "./smartnginx.command";
|
||||
|
||||
// classes
|
||||
export {NginxConfig,NginxZone} from "./smartnginx.classes.nginxconfig";
|
||||
export {NginxConfig} from "./smartnginx.classes.nginxconfig";
|
||||
export {NginxZone,zoneTypes} from "./smartnginx.classes.nginxzone";
|
||||
|
||||
// exports
|
||||
export let command = CommandModule;
|
@ -1,11 +1,13 @@
|
||||
import * as plugins from "./smartnginx.plugins";
|
||||
|
||||
export enum ZoneTypes {
|
||||
|
||||
}
|
||||
import * as paths from "./smartnginx.paths";
|
||||
import * as command from "./smartnginx.command";
|
||||
import * as snippets from "./smartnginx.snippets"
|
||||
import {NginxZone} from "./smartnginx.classes.nginxzone";
|
||||
let allConfigs:NginxConfig[] = [];
|
||||
|
||||
export class NginxConfig {
|
||||
zones:NginxZone[];
|
||||
isDeployed:boolean = false;
|
||||
constructor(){
|
||||
|
||||
};
|
||||
@ -22,26 +24,23 @@ export class NginxConfig {
|
||||
}
|
||||
|
||||
// handle deployment of zones
|
||||
deploy(){
|
||||
|
||||
deploy(nginxRestartArg:boolean = false){
|
||||
plugins.smartfile.fs.remove(paths.nginxConfigBase);
|
||||
plugins.smartfile.fs.ensureDir(paths.nginxConfigBase);
|
||||
for(let config of allConfigs){
|
||||
config.isDeployed = false;
|
||||
};
|
||||
nginxStart(){
|
||||
|
||||
this.isDeployed = true;
|
||||
for(let zone of this.zones){
|
||||
zone.deploy();
|
||||
};
|
||||
nginxStop(){
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
export class NginxZone {
|
||||
domain
|
||||
constructor(optionsArg:{
|
||||
zoneName:string,
|
||||
type:ZoneTypes,
|
||||
destination:string
|
||||
}){
|
||||
|
||||
}
|
||||
plugins.smartfile.memory.toFsSync(
|
||||
snippets.getBaseConfigString(),
|
||||
plugins.path.join(paths.nginxConfigBase,"nginx.conf")
|
||||
);
|
||||
if(nginxRestartArg){
|
||||
command.restart(this);
|
||||
}
|
||||
};
|
||||
|
||||
let mynginx = new NginxConfig();
|
||||
};
|
||||
|
24
ts/smartnginx.classes.nginxzone.ts
Normal file
24
ts/smartnginx.classes.nginxzone.ts
Normal file
@ -0,0 +1,24 @@
|
||||
import * as plugins from "./smartnginx.plugins";
|
||||
import * as paths from "./smartnginx.paths";
|
||||
import * as command from "./smartnginx.command";
|
||||
import * as snippets from "./smartnginx.snippets"
|
||||
export enum zoneTypes {
|
||||
reverseProxy,
|
||||
static
|
||||
}
|
||||
|
||||
export class NginxZone {
|
||||
zoneName:string; // the zone name e.g. domain name
|
||||
configString:string; // the actual zone config file as string
|
||||
constructor(optionsArg:{
|
||||
zoneName:string,
|
||||
type:zoneTypes,
|
||||
destination:string
|
||||
}){
|
||||
this.configString = snippets.getZoneConfigString(optionsArg.zoneName,optionsArg.destination);
|
||||
};
|
||||
deploy(){
|
||||
let filePath = plugins.path.join(paths.nginxZoneBase,this.zoneName + ".conf");
|
||||
plugins.smartfile.memory.toFsSync(this.configString,filePath);
|
||||
};
|
||||
};
|
29
ts/smartnginx.command.ts
Normal file
29
ts/smartnginx.command.ts
Normal file
@ -0,0 +1,29 @@
|
||||
import * as plugins from "./smartnginx.plugins";
|
||||
import {NginxConfig} from "./smartnginx.classes.nginxconfig";
|
||||
import {NginxZone} from "./smartnginx.classes.nginxzone";
|
||||
|
||||
/**
|
||||
* starts nginx
|
||||
*/
|
||||
export let start = (configArg:NginxConfig) => {
|
||||
|
||||
};
|
||||
|
||||
export let restart = (configArg:NginxConfig) => {
|
||||
stop();
|
||||
start(configArg);
|
||||
}
|
||||
|
||||
/**
|
||||
* stops nginx
|
||||
*/
|
||||
export let stop = () => {
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* checks if nginx is in path
|
||||
*/
|
||||
export let check = ():boolean => {
|
||||
return;
|
||||
};
|
5
ts/smartnginx.paths.ts
Normal file
5
ts/smartnginx.paths.ts
Normal file
@ -0,0 +1,5 @@
|
||||
import * as plugins from "./smartnginx.plugins"
|
||||
|
||||
export let packageBase = plugins.path.join(__dirname,"../");
|
||||
export let nginxConfigBase = plugins.path.join(packageBase,"nginxconfig/");
|
||||
export let nginxZoneBase = plugins.path.join(nginxConfigBase,"zones");
|
@ -1,3 +1,7 @@
|
||||
import "typings-global";
|
||||
export import cert = require("cert");
|
||||
export import path = require("path");
|
||||
export import q = require("q");
|
||||
export let shelljs = require("shelljs");
|
||||
export import smartfile = require("smartfile");
|
||||
export import smartstring = require("smartstring");
|
102
ts/smartnginx.snippets.ts
Normal file
102
ts/smartnginx.snippets.ts
Normal file
@ -0,0 +1,102 @@
|
||||
import * as plugins from "./smartnginx.plugins";
|
||||
export let 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 /etc/nginx/conf.d/*.conf;
|
||||
include /etc/nginx/sites-enabled/*;
|
||||
}
|
||||
daemon off;
|
||||
`);
|
||||
}
|
||||
|
||||
|
||||
export let getZoneConfigString = (zoneNameArg:string,destinationIpArg:string) => {
|
||||
let zoneConfig = plugins.smartstring.indent.normalize(`
|
||||
upstream ${zoneNameArg} {
|
||||
server ${destinationIpArg};
|
||||
}
|
||||
|
||||
server {
|
||||
listen *:80 ;
|
||||
server_name ${zoneNameArg};
|
||||
rewrite ^ https://${zoneNameArg}$request_uri? permanent;
|
||||
}
|
||||
|
||||
server {
|
||||
listen *:443 ssl;
|
||||
server_name ${zoneNameArg};
|
||||
ssl_certificate /LE_CERTS/${zoneNameArg}/fullchain.pem;
|
||||
ssl_certificate_key /LE_CERTS/${zoneNameArg}/privkey.pem;
|
||||
|
||||
location / {
|
||||
proxy_pass http://${zoneNameArg};
|
||||
include /etc/nginx/proxy_params;
|
||||
}
|
||||
location ~ /\.git {
|
||||
deny all;
|
||||
}
|
||||
}
|
||||
`);
|
||||
return zoneConfig;
|
||||
};
|
||||
|
Reference in New Issue
Block a user