Compare commits

...

34 Commits

Author SHA1 Message Date
2c81f8b492 2.0.36 2019-01-22 22:07:59 +01:00
0fe7d586cf fix(core): update 2019-01-22 22:07:58 +01:00
a4c8b789ad 2.0.35 2019-01-22 22:05:03 +01:00
b4378e305a fix(core): update 2019-01-22 22:05:02 +01:00
5ff0980908 2.0.34 2019-01-22 18:59:56 +01:00
e60257d761 fix(core): update 2019-01-22 18:59:55 +01:00
e94f0edafb 2.0.33 2019-01-22 18:25:44 +01:00
c417d96e48 fix(core): update 2019-01-22 18:25:43 +01:00
c5b1dbb46e 2.0.32 2019-01-22 12:33:48 +01:00
893a2e2709 fix(core): update 2019-01-22 12:33:47 +01:00
01f0dc6b20 2.0.31 2019-01-22 12:11:32 +01:00
736a42066c fix(core): update 2019-01-22 12:11:31 +01:00
44403863d1 2.0.30 2019-01-22 12:03:00 +01:00
5be21fa100 fix(core): update 2019-01-22 12:02:59 +01:00
042167c01e 2.0.29 2019-01-22 04:03:17 +01:00
db38d038ef fix(core): update 2019-01-22 04:03:17 +01:00
a4d8a46360 2.0.28 2019-01-19 15:57:50 +01:00
84e5c10129 fix(core): update 2019-01-19 15:57:49 +01:00
98a2871f08 2.0.27 2019-01-19 15:42:46 +01:00
9bb847210a fix(core): update 2019-01-19 15:42:45 +01:00
91d4ba5715 2.0.26 2019-01-19 15:41:51 +01:00
3ee2988964 fix(core): update 2019-01-19 15:41:51 +01:00
221f1f6237 2.0.25 2019-01-19 12:17:47 +01:00
0a6fbf588e fix(core): update 2019-01-19 12:17:47 +01:00
1a8546af6e 2.0.24 2019-01-19 11:07:14 +01:00
9e01bdb8e2 fix(core): update 2019-01-19 11:07:14 +01:00
33833fbc6c 2.0.23 2019-01-19 10:59:25 +01:00
97b5678fe4 fix(core): update 2019-01-19 10:59:24 +01:00
9b96984413 2.0.22 2019-01-19 03:21:27 +01:00
0de412b842 fix(core): update 2019-01-19 03:21:27 +01:00
64bcce9e23 2.0.21 2019-01-19 03:04:38 +01:00
390812ec33 fix(core): update 2019-01-19 03:04:38 +01:00
a672bb920f 2.0.20 2019-01-19 02:46:41 +01:00
c3fabb6107 fix(core): update 2019-01-19 02:46:41 +01:00
8 changed files with 73 additions and 19 deletions

46
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "@pushrocks/smartnginx",
"version": "2.0.19",
"version": "2.0.36",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@ -248,6 +248,17 @@
"luxon": "^1.8.0"
}
},
"@pushrocks/smartunique": {
"version": "3.0.1",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartunique/-/smartunique-3.0.1.tgz",
"integrity": "sha512-xBu9ZB4C0BA0S/pbFFZn2ItPfnodPKpzrYIq1yN5XDs6OaookwcDF/iBwfS9+EYMSPENC9wAsOxg2RGMm4Qicw==",
"requires": {
"@types/shortid": "^0.0.29",
"@types/uuid": "^3.0.0",
"shortid": "^2.2.8",
"uuid": "^3.1.0"
}
},
"@pushrocks/tapbundle": {
"version": "3.0.7",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2ftapbundle/-/tapbundle-3.0.7.tgz",
@ -322,6 +333,19 @@
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.5.7.tgz",
"integrity": "sha512-VkKcfuitP+Nc/TaTFH0B8qNmn+6NbI6crLkQonbedViVz7O2w8QV/GERPlkJ4bg42VGHiEWa31CoTOPs1q6z1w=="
},
"@types/shortid": {
"version": "0.0.29",
"resolved": "https://verdaccio.lossless.one/@types%2fshortid/-/shortid-0.0.29.tgz",
"integrity": "sha1-gJPuBBam4r8qpjOBCRFLP7/6Dps="
},
"@types/uuid": {
"version": "3.4.4",
"resolved": "https://verdaccio.lossless.one/@types%2fuuid/-/uuid-3.4.4.tgz",
"integrity": "sha512-tPIgT0GUmdJQNSHxp0X2jnpQfBSTfGxUMc/2CXBU2mnyTFVYVa2ojpoQ74w0U2yn2vw3jnC640+77lkFFpdVDw==",
"requires": {
"@types/node": "*"
}
},
"@types/vinyl": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/@types/vinyl/-/vinyl-2.0.2.tgz",
@ -332,7 +356,7 @@
},
"@types/which": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/@types/which/-/which-1.3.1.tgz",
"resolved": "https://verdaccio.lossless.one/@types%2fwhich/-/which-1.3.1.tgz",
"integrity": "sha512-ZrJDWpvg75LTGX4XwuneY9s6bF3OeZcGTpoGh3zDV9ytzcHMFsRrMIaLBRJZQMBoGyKs6unBQfVdrLZiYfb1zQ=="
},
"@types/yargs": {
@ -1036,6 +1060,11 @@
"integrity": "sha512-JY7V6lRkStKcKTvHO5NVSQRv+RV+FIL5pvDoLiAtSL9pKlC5x9PKQcZDsq7m4FO4d57mkhC6Z+QhAh3Jdk5JFw==",
"dev": true
},
"nanoid": {
"version": "2.0.1",
"resolved": "https://verdaccio.lossless.one/nanoid/-/nanoid-2.0.1.tgz",
"integrity": "sha512-k1u2uemjIGsn25zmujKnotgniC/gxQ9sdegdezeDiKdkDW56THUMqlz3urndKCXJxA6yPzSZbXx/QCMe/pxqsA=="
},
"nice-try": {
"version": "1.0.5",
"resolved": "https://verdaccio.lossless.one/nice-try/-/nice-try-1.0.5.tgz",
@ -1273,6 +1302,14 @@
"integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=",
"dev": true
},
"shortid": {
"version": "2.2.14",
"resolved": "https://verdaccio.lossless.one/shortid/-/shortid-2.2.14.tgz",
"integrity": "sha512-4UnZgr9gDdA1kaKj/38IiudfC3KHKhDc1zi/HSxd9FQDR0VLwH3/y79tZJLsVYPsJgIjeHjqIWaWVRJUj9qZOQ==",
"requires": {
"nanoid": "^2.0.0"
}
},
"signal-exit": {
"version": "3.0.2",
"resolved": "https://verdaccio.lossless.one/signal-exit/-/signal-exit-3.0.2.tgz",
@ -1466,6 +1503,11 @@
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
"integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
},
"uuid": {
"version": "3.3.2",
"resolved": "https://verdaccio.lossless.one/uuid/-/uuid-3.3.2.tgz",
"integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA=="
},
"vinyl": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/vinyl/-/vinyl-2.2.0.tgz",

View File

@ -1,6 +1,6 @@
{
"name": "@pushrocks/smartnginx",
"version": "2.0.19",
"version": "2.0.36",
"private": false,
"description": "control nginx from node, TypeScript ready",
"main": "dist/index.js",
@ -29,7 +29,8 @@
"@pushrocks/smartlog": "^2.0.11",
"@pushrocks/smartpromise": "^2.0.5",
"@pushrocks/smartshell": "^2.0.13",
"@pushrocks/smartstring": "^3.0.8"
"@pushrocks/smartstring": "^3.0.8",
"@pushrocks/smartunique": "^3.0.1"
},
"devDependencies": {
"@gitzone/tsbuild": "^2.1.4",

View File

@ -19,12 +19,14 @@ tap.test(`should produce an instance of NginxConfig`, async () => {
testNginxZone01 = new smartnginx.NginxHost(testSmartNginx, {
hostName: 'test100.bleu.de',
destination: '192.192.192.191',
destinationPort: 3000,
privateKey: 'some private',
publicKey: 'some public'
});
testNginxZone02 = new smartnginx.NginxHost(testSmartNginx, {
hostName: 'test102.bleu.de',
destination: '192.192.192.192',
destinationPort: 3050,
privateKey: 'some private',
publicKey: 'some public'
});

View File

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

View File

@ -21,6 +21,7 @@ export class NginxHost implements IHostConfig {
public hostName: string; // the host name e.g. domain name
public destination: string;
public destinationPort: number;
public configString: string; // the actual host config file as string
public privateKey: string;
public publicKey: string;
@ -29,7 +30,7 @@ export class NginxHost implements IHostConfig {
this.smartnginxInstance = smartnginxInstanceArg;
this.hostName = optionsArg.hostName;
this.destination = optionsArg.destination;
this.configString = snippets.getHostConfigString(optionsArg.hostName, optionsArg.destination);
this.destinationPort = optionsArg.destinationPort;
this.privateKey = optionsArg.privateKey;
this.publicKey = optionsArg.publicKey;
}
@ -42,7 +43,10 @@ export class NginxHost implements IHostConfig {
const filePathConfig = plugins.path.join(paths.nginxHostDirPath, `${this.hostName}.conf`);
const filePathPrivate = plugins.path.join(paths.nginxHostDirPath, `${this.hostName}.private.pem`);
const filePathPublic = plugins.path.join(paths.nginxHostDirPath, `${this.hostName}.public.pem`);
// writeConfig
this.configString = snippets.getHostConfigString(this.hostName, this.destination, this.destinationPort);
plugins.smartfile.memory.toFsSync(this.configString, filePathConfig);
// write ssl

View File

@ -78,7 +78,8 @@ export class SmartNginx {
await this.deployedHosts.forEach(async deployedHostArg => {
if (
hostCandidateArg.hostName === deployedHostArg.hostName &&
hostCandidateArg.destination === deployedHostArg.destination
hostCandidateArg.destination === deployedHostArg.destination &&
hostCandidateArg.destinationPort === deployedHostArg.destinationPort
) {
hostCounter++;
foundHost = true;

View File

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

View File

@ -1,7 +1,7 @@
import * as plugins from './smartnginx.plugins';
import * as paths from './smartnginx.paths';
export let getBaseConfigString = () => {
let baseConfig = plugins.smartstring.indent.normalize(`
const baseConfig = plugins.smartstring.indent.normalize(`
user www-data;
worker_processes auto;
pid /run/nginx/nginx.pid;
@ -71,13 +71,17 @@ export let getBaseConfigString = () => {
return baseConfig;
};
export let getHostConfigString = (hostNameArg: string, destinationIpArg: string) => {
let hostConfig = plugins.smartstring.indent.normalize(`
export let getHostConfigString = (hostNameArg: string, destinationIpArg: string, destinationPortArg = 80) => {
const hostConfig = plugins.smartstring.indent.normalize(`
upstream ${hostNameArg} {
server ${destinationIpArg};
keepalive 100;
server ${destinationIpArg}:${destinationPortArg};
}
server {
# The keepalive parameter sets the maximum number of idle keepalive connections
# to upstream servers that are preserved in the cache of each worker process. When
# this number is exceeded, the least recently used connections are closed.
listen *:80 ;
server_name ${hostNameArg};
rewrite ^ https://${hostNameArg}$request_uri? permanent;
@ -88,15 +92,13 @@ export let getHostConfigString = (hostNameArg: string, destinationIpArg: string)
server_name ${hostNameArg};
ssl_certificate ${paths.nginxHostDirPath}/${hostNameArg}.public.pem;
ssl_certificate_key ${paths.nginxHostDirPath}/${hostNameArg}.private.pem;
location / {
proxy_http_version 1.1;
keepalive 100;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://${hostNameArg};
proxy_http_version 1.1;
proxy_buffering off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://${hostNameArg};
}
}
`);