now includes snippets
This commit is contained in:
parent
8ebde757b2
commit
a15f05cedb
3
dist/index.d.ts
vendored
3
dist/index.d.ts
vendored
@ -1,3 +1,4 @@
|
||||
import * as CommandModule from "./smartnginx.command";
|
||||
export { NginxConfig, NginxZone } from "./smartnginx.classes.nginxconfig";
|
||||
export { NginxConfig } from "./smartnginx.classes.nginxconfig";
|
||||
export { NginxZone, zoneTypes } from "./smartnginx.classes.nginxzone";
|
||||
export declare let command: typeof CommandModule;
|
||||
|
6
dist/index.js
vendored
6
dist/index.js
vendored
@ -3,7 +3,9 @@ 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;
|
||||
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQ0EsSUFBWSxhQUFhLFdBQU0sc0JBQXNCLENBQUMsQ0FBQTtBQUV0RCxVQUFVO0FBQ1YsK0NBQW9DLGtDQUFrQyxDQUFDO0FBQS9ELG1FQUFXO0FBQUMsK0RBQW1EO0FBRXZFLFVBQVU7QUFDQyxlQUFPLEdBQUcsYUFBYSxDQUFDIn0=
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQ0EsSUFBWSxhQUFhLFdBQU0sc0JBQXNCLENBQUMsQ0FBQTtBQUV0RCxVQUFVO0FBQ1YsK0NBQTBCLGtDQUFrQyxDQUFDO0FBQXJELG1FQUFxRDtBQUM3RCw2Q0FBa0MsZ0NBQWdDLENBQUM7QUFBM0QsNkRBQVM7QUFBQyw2REFBaUQ7QUFFbkUsVUFBVTtBQUNDLGVBQU8sR0FBRyxhQUFhLENBQUMifQ==
|
13
dist/smartnginx.classes.nginxconfig.d.ts
vendored
13
dist/smartnginx.classes.nginxconfig.d.ts
vendored
@ -1,5 +1,4 @@
|
||||
export declare enum ZoneTypes {
|
||||
}
|
||||
import { NginxZone } from "./smartnginx.classes.nginxzone";
|
||||
export declare class NginxConfig {
|
||||
zones: NginxZone[];
|
||||
isDeployed: boolean;
|
||||
@ -9,13 +8,3 @@ export declare class NginxConfig {
|
||||
removeZones(zoneArg: NginxZone): void;
|
||||
deploy(nginxRestartArg?: boolean): void;
|
||||
}
|
||||
export declare class NginxZone {
|
||||
zoneName: string;
|
||||
configString: string;
|
||||
constructor(optionsArg: {
|
||||
zoneName: string;
|
||||
type: ZoneTypes;
|
||||
destination: string;
|
||||
});
|
||||
deploy(): void;
|
||||
}
|
||||
|
18
dist/smartnginx.classes.nginxconfig.js
vendored
18
dist/smartnginx.classes.nginxconfig.js
vendored
@ -2,9 +2,6 @@
|
||||
var plugins = require("./smartnginx.plugins");
|
||||
var paths = require("./smartnginx.paths");
|
||||
var command = require("./smartnginx.command");
|
||||
(function (ZoneTypes) {
|
||||
})(exports.ZoneTypes || (exports.ZoneTypes = {}));
|
||||
var ZoneTypes = exports.ZoneTypes;
|
||||
var allConfigs = [];
|
||||
var NginxConfig = (function () {
|
||||
function NginxConfig() {
|
||||
@ -44,17 +41,4 @@ var NginxConfig = (function () {
|
||||
}());
|
||||
exports.NginxConfig = NginxConfig;
|
||||
;
|
||||
var NginxZone = (function () {
|
||||
function NginxZone(optionsArg) {
|
||||
}
|
||||
;
|
||||
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;
|
||||
var mynginx = new NginxConfig();
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRuZ2lueC5jbGFzc2VzLm5naW54Y29uZmlnLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRuZ2lueC5jbGFzc2VzLm5naW54Y29uZmlnLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxJQUFZLE9BQU8sV0FBTSxzQkFBc0IsQ0FBQyxDQUFBO0FBQ2hELElBQVksS0FBSyxXQUFNLG9CQUFvQixDQUFDLENBQUE7QUFDNUMsSUFBWSxPQUFPLFdBQU0sc0JBQXNCLENBQUMsQ0FBQTtBQUVoRCxXQUFZLFNBQVM7QUFFckIsQ0FBQyxFQUZXLGlCQUFTLEtBQVQsaUJBQVMsUUFFcEI7QUFGRCxJQUFZLFNBQVMsR0FBVCxpQkFFWCxDQUFBO0FBRUQsSUFBSSxVQUFVLEdBQWlCLEVBQUUsQ0FBQztBQUVsQztJQUdJO1FBREEsZUFBVSxHQUFXLEtBQUssQ0FBQztJQUczQixDQUFDOztJQUVELHNCQUFzQjtJQUN0Qiw2QkFBTyxHQUFQLFVBQVEsT0FBaUI7SUFFekIsQ0FBQztJQUNELCtCQUFTLEdBQVQ7UUFDSSxNQUFNLENBQUMsSUFBSSxDQUFDLEtBQUssQ0FBQztJQUN0QixDQUFDOztJQUNELGlDQUFXLEdBQVgsVUFBWSxPQUFpQjtJQUU3QixDQUFDO0lBRUQsNkJBQTZCO0lBQzdCLDRCQUFNLEdBQ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EMsT0FBTyxDQUFDLFNBQVMsQ0FBQyxFQUFFLENBQUMsTUFBTSxDQUFDLEtBQUssQ0FBQyxhQUFhLENBQUMsQ0FBQztRQUNqRCxPQUFPLENBQUMsU0FBUyxDQUFDLEVBQUUsQ0FBQyxTQUFTLENBQUMsS0FBSyxDQUFDLGFBQWEsQ0FBQyxDQUFDO1FBQ3BELEdBQUcsQ0FBQSxDQUFlLFVBQVUsRUFBVix5QkFBVSxFQUFWLHdCQUFVLEVBQVYsSUFBVSxDQUFDO1lBQXpCLElBQUksTUFBTSxtQkFBQTtZQUNWLE1BQU0sQ0FBQyxVQUFVLEdBQUcsS0FBSyxDQUFDO1NBQzdCO1FBQUEsQ0FBQztRQUNGLElBQUksQ0FBQyxVQUFVLEdBQUcsSUFBSSxDQUFDO1FBQ3ZCLEdBQUcsQ0FBQSxDQUFhLFVBQVUsRUFBVixLQUFBLElBQUksQ0FBQyxLQUFLLEVBQVYsY0FBVSxFQUFWLElBQVUsQ0FBQztZQUF2QixJQUFJLElBQUksU0FBQTtZQUNSLElBQUksQ0FBQyxNQUFNLEVBQUUsQ0FBQztTQUNqQjtRQUNELEVBQUUsQ0FBQSxDQUFDLGVBQWUsQ0FBQyxDQUFBLENBQUM7WUFDaEIsT0FBTyxDQUFDLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FBQztRQUMxQixDQUFDO0lBQ0wsQ0FBQzs7SUFFTCxrQkFBQztBQUFELENBQUMsQUFsQ0QsSUFrQ0M7QUFsQ1ksbUJBQVcsY0FrQ3ZCLENBQUE7QUFBQSxDQUFDIn0=
|
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
|
2
dist/smartnginx.command.js
vendored
2
dist/smartnginx.command.js
vendored
@ -19,4 +19,4 @@ exports.stop = function () {
|
||||
exports.check = function () {
|
||||
return;
|
||||
};
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRuZ2lueC5jb21tYW5kLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRuZ2lueC5jb21tYW5kLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFHQTs7R0FFRztBQUNRLGFBQUssR0FBRyxVQUFDLFNBQXFCO0FBRXpDLENBQUMsQ0FBQztBQUVTLGVBQU8sR0FBRyxVQUFDLFNBQXFCO0lBQ3ZDLFlBQUksRUFBRSxDQUFDO0lBQ1AsYUFBSyxDQUFDLFNBQVMsQ0FBQyxDQUFDO0FBQ3JCLENBQUMsQ0FBQTtBQUVEOztHQUVHO0FBQ1EsWUFBSSxHQUFHO0FBRWxCLENBQUMsQ0FBQztBQUVGOztHQUVHO0FBQ1EsYUFBSyxHQUFHO0lBQ2YsTUFBTSxDQUFDO0FBQ1gsQ0FBQyxDQUFDIn0=
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRuZ2lueC5jb21tYW5kLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRuZ2lueC5jb21tYW5kLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFJQTs7R0FFRztBQUNRLGFBQUssR0FBRyxVQUFDLFNBQXFCO0FBRXpDLENBQUMsQ0FBQztBQUVTLGVBQU8sR0FBRyxVQUFDLFNBQXFCO0lBQ3ZDLFlBQUksRUFBRSxDQUFDO0lBQ1AsYUFBSyxDQUFDLFNBQVMsQ0FBQyxDQUFDO0FBQ3JCLENBQUMsQ0FBQTtBQUVEOztHQUVHO0FBQ1EsWUFBSSxHQUFHO0FBRWxCLENBQUMsQ0FBQztBQUVGOztHQUVHO0FBQ1EsYUFBSyxHQUFHO0lBQ2YsTUFBTSxDQUFDO0FBQ1gsQ0FBQyxDQUFDIn0=
|
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;
|
9
dist/smartnginx.snippets.js
vendored
Normal file
9
dist/smartnginx.snippets.js
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
"use strict";
|
||||
exports.getBaseConfigString = function () {
|
||||
var baseConfig = "\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 = ("\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").trim();
|
||||
return zoneConfig;
|
||||
};
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRuZ2lueC5zbmlwcGV0cy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0bmdpbnguc25pcHBldHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFXLDJCQUFtQixHQUFHO0lBQ2hDLElBQUksVUFBVSxHQUFHLDY0Q0FrRWhCLENBQUM7QUFDSCxDQUFDLENBQUE7QUFHVSwyQkFBbUIsR0FBRyxVQUFDLFdBQWtCLEVBQUMsZ0JBQXVCO0lBQzNFLElBQUksVUFBVSxHQUFHLHFCQUNMLFdBQVcseUJBQ1osZ0JBQWdCLHlFQUtYLFdBQVcsMENBQ0UsV0FBVyxvR0FLeEIsV0FBVywyQ0FDRyxXQUFXLDZEQUNQLFdBQVcsdUVBR3RCLFdBQVcsMkhBT2pDLENBQUMsSUFBSSxFQUFFLENBQUM7SUFDVCxNQUFNLENBQUMsVUFBVSxDQUFDO0FBQ25CLENBQUMsQ0FBQyJ9
|
@ -25,7 +25,8 @@
|
||||
"cert": "0.0.13",
|
||||
"q": "^1.4.1",
|
||||
"shelljs": "^0.7.0",
|
||||
"smartfile": "^4.0.10"
|
||||
"smartfile": "^4.0.10",
|
||||
"smartstring": "^2.0.10"
|
||||
},
|
||||
"devDependencies": {
|
||||
"npmts-g": "^5.2.6",
|
||||
|
14
test/test.js
14
test/test.js
@ -5,6 +5,18 @@ 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();
|
||||
@ -12,4 +24,4 @@ describe("smartnginx", function () {
|
||||
});
|
||||
});
|
||||
});
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sY0FBYyxDQUFDLENBQUE7QUFDdEIsUUFBTyxRQUFRLENBQUMsQ0FBQTtBQUNoQixJQUFZLFVBQVUsV0FBTSxlQUFlLENBQUMsQ0FBQTtBQUU1QyxRQUFRLENBQUMsWUFBWSxFQUFDO0lBQ2xCLElBQUksZUFBc0MsQ0FBQztJQUMzQyxJQUFJLGVBQW9DLENBQUM7SUFDekMsUUFBUSxDQUFDLGFBQWEsRUFBQztRQUNuQixFQUFFLENBQUMsaUVBQStELEVBQUM7WUFDL0QsZUFBZSxHQUFHLElBQUksVUFBVSxDQUFDLFdBQVcsRUFBR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QUFDLENBQUMsQ0FBQztJQUNILFFBQVEsQ0FBQyxhQUFhLEVBQUM7UUFDbkIsRUFBRSxDQUFDLGlFQUErRCxFQUFDO1lBQy9ELGVBQWUsR0FBRyxJQUFJLFVBQVUsQ0FBQyxXQUFXLEVBQUUsQ0FBQztZQUMvQyxlQUFlLENBQUMsTUFBTSxDQUFDLEVBQUUsQ0FBQyxVQUFVLENBQUMsVUFBVSxDQUFDLFdBQVcsQ0FBQyxDQUFDO1FBQ2pFLENBQUMsQ0FBQyxDQUFDO0lBQ1AsQ0FBQyxDQUFDLENBQUM7QUFDUCxDQUFDLENBQUMsQ0FBQyJ9
|
17
test/test.ts
17
test/test.ts
@ -5,11 +5,22 @@ 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);
|
||||
});
|
||||
|
||||
})
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -2,7 +2,8 @@ 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,7 @@
|
||||
import * as plugins from "./smartnginx.plugins";
|
||||
import * as paths from "./smartnginx.paths";
|
||||
import * as command from "./smartnginx.command";
|
||||
|
||||
export enum ZoneTypes {
|
||||
|
||||
}
|
||||
|
||||
import {NginxZone} from "./smartnginx.classes.nginxzone";
|
||||
let allConfigs:NginxConfig[] = [];
|
||||
|
||||
export class NginxConfig {
|
||||
@ -43,21 +39,3 @@ export class NginxConfig {
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
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
|
||||
}){
|
||||
|
||||
};
|
||||
deploy(){
|
||||
let filePath = plugins.path.join(paths.nginxZoneBase,this.zoneName + ".conf");
|
||||
plugins.smartfile.memory.toFsSync(this.configString,filePath);
|
||||
};
|
||||
}
|
||||
|
||||
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);
|
||||
};
|
||||
};
|
@ -1,5 +1,6 @@
|
||||
import * as plugins from "./smartnginx.plugins";
|
||||
import {NginxConfig,NginxZone} from "./smartnginx.classes.nginxconfig";
|
||||
import {NginxConfig} from "./smartnginx.classes.nginxconfig";
|
||||
import {NginxZone} from "./smartnginx.classes.nginxzone";
|
||||
|
||||
/**
|
||||
* starts nginx
|
||||
|
@ -1,71 +1,101 @@
|
||||
let baseConfig = `
|
||||
user www-data;
|
||||
worker_processes auto;
|
||||
pid /run/nginx.pid;
|
||||
export let getBaseConfigString = () => {
|
||||
let baseConfig = `
|
||||
user www-data;
|
||||
worker_processes auto;
|
||||
pid /run/nginx.pid;
|
||||
|
||||
events {
|
||||
worker_connections 768;
|
||||
# multi_accept on;
|
||||
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;
|
||||
`;
|
||||
}
|
||||
|
||||
http {
|
||||
server_names_hash_bucket_size 128;
|
||||
|
||||
##
|
||||
# Basic Settings
|
||||
##
|
||||
export let getZoneConfigString = (zoneNameArg:string,destinationIpArg:string) => {
|
||||
let zoneConfig = `
|
||||
upstream ${zoneNameArg} {
|
||||
server ${destinationIpArg};
|
||||
}
|
||||
|
||||
sendfile on;
|
||||
tcp_nopush on;
|
||||
tcp_nodelay on;
|
||||
keepalive_timeout 65;
|
||||
types_hash_max_size 2048;
|
||||
# server_tokens off;
|
||||
server {
|
||||
listen *:80 ;
|
||||
server_name ${zoneNameArg};
|
||||
rewrite ^ https://${zoneNameArg}$request_uri? permanent;
|
||||
}
|
||||
|
||||
# server_names_hash_bucket_size 64;
|
||||
# server_name_in_redirect off;
|
||||
server {
|
||||
listen *:443 ssl;
|
||||
server_name ${zoneNameArg};
|
||||
ssl_certificate /LE_CERTS/${zoneNameArg}/fullchain.pem;
|
||||
ssl_certificate_key /LE_CERTS/${zoneNameArg}/privkey.pem;
|
||||
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
location / {
|
||||
proxy_pass http://${zoneNameArg};
|
||||
include /etc/nginx/proxy_params;
|
||||
}
|
||||
location ~ /\.git {
|
||||
deny all;
|
||||
}
|
||||
}
|
||||
`;
|
||||
return zoneConfig;
|
||||
};
|
||||
|
||||
##
|
||||
# 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;
|
||||
`
|
||||
|
||||
let zoneConfig = `
|
||||
|
||||
`
|
Loading…
Reference in New Issue
Block a user