Compare commits
28 Commits
Author | SHA1 | Date | |
---|---|---|---|
a4c8b789ad | |||
b4378e305a | |||
5ff0980908 | |||
e60257d761 | |||
e94f0edafb | |||
c417d96e48 | |||
c5b1dbb46e | |||
893a2e2709 | |||
01f0dc6b20 | |||
736a42066c | |||
44403863d1 | |||
5be21fa100 | |||
042167c01e | |||
db38d038ef | |||
a4d8a46360 | |||
84e5c10129 | |||
98a2871f08 | |||
9bb847210a | |||
91d4ba5715 | |||
3ee2988964 | |||
221f1f6237 | |||
0a6fbf588e | |||
1a8546af6e | |||
9e01bdb8e2 | |||
33833fbc6c | |||
97b5678fe4 | |||
9b96984413 | |||
0de412b842 |
46
package-lock.json
generated
46
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartnginx",
|
"name": "@pushrocks/smartnginx",
|
||||||
"version": "2.0.21",
|
"version": "2.0.35",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@ -248,6 +248,17 @@
|
|||||||
"luxon": "^1.8.0"
|
"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": {
|
"@pushrocks/tapbundle": {
|
||||||
"version": "3.0.7",
|
"version": "3.0.7",
|
||||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2ftapbundle/-/tapbundle-3.0.7.tgz",
|
"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",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.5.7.tgz",
|
||||||
"integrity": "sha512-VkKcfuitP+Nc/TaTFH0B8qNmn+6NbI6crLkQonbedViVz7O2w8QV/GERPlkJ4bg42VGHiEWa31CoTOPs1q6z1w=="
|
"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": {
|
"@types/vinyl": {
|
||||||
"version": "2.0.2",
|
"version": "2.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/@types/vinyl/-/vinyl-2.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/@types/vinyl/-/vinyl-2.0.2.tgz",
|
||||||
@ -332,7 +356,7 @@
|
|||||||
},
|
},
|
||||||
"@types/which": {
|
"@types/which": {
|
||||||
"version": "1.3.1",
|
"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=="
|
"integrity": "sha512-ZrJDWpvg75LTGX4XwuneY9s6bF3OeZcGTpoGh3zDV9ytzcHMFsRrMIaLBRJZQMBoGyKs6unBQfVdrLZiYfb1zQ=="
|
||||||
},
|
},
|
||||||
"@types/yargs": {
|
"@types/yargs": {
|
||||||
@ -1036,6 +1060,11 @@
|
|||||||
"integrity": "sha512-JY7V6lRkStKcKTvHO5NVSQRv+RV+FIL5pvDoLiAtSL9pKlC5x9PKQcZDsq7m4FO4d57mkhC6Z+QhAh3Jdk5JFw==",
|
"integrity": "sha512-JY7V6lRkStKcKTvHO5NVSQRv+RV+FIL5pvDoLiAtSL9pKlC5x9PKQcZDsq7m4FO4d57mkhC6Z+QhAh3Jdk5JFw==",
|
||||||
"dev": true
|
"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": {
|
"nice-try": {
|
||||||
"version": "1.0.5",
|
"version": "1.0.5",
|
||||||
"resolved": "https://verdaccio.lossless.one/nice-try/-/nice-try-1.0.5.tgz",
|
"resolved": "https://verdaccio.lossless.one/nice-try/-/nice-try-1.0.5.tgz",
|
||||||
@ -1273,6 +1302,14 @@
|
|||||||
"integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=",
|
"integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=",
|
||||||
"dev": true
|
"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": {
|
"signal-exit": {
|
||||||
"version": "3.0.2",
|
"version": "3.0.2",
|
||||||
"resolved": "https://verdaccio.lossless.one/signal-exit/-/signal-exit-3.0.2.tgz",
|
"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",
|
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
|
||||||
"integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
|
"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": {
|
"vinyl": {
|
||||||
"version": "2.2.0",
|
"version": "2.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/vinyl/-/vinyl-2.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/vinyl/-/vinyl-2.2.0.tgz",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartnginx",
|
"name": "@pushrocks/smartnginx",
|
||||||
"version": "2.0.21",
|
"version": "2.0.35",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "control nginx from node, TypeScript ready",
|
"description": "control nginx from node, TypeScript ready",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
@ -29,7 +29,8 @@
|
|||||||
"@pushrocks/smartlog": "^2.0.11",
|
"@pushrocks/smartlog": "^2.0.11",
|
||||||
"@pushrocks/smartpromise": "^2.0.5",
|
"@pushrocks/smartpromise": "^2.0.5",
|
||||||
"@pushrocks/smartshell": "^2.0.13",
|
"@pushrocks/smartshell": "^2.0.13",
|
||||||
"@pushrocks/smartstring": "^3.0.8"
|
"@pushrocks/smartstring": "^3.0.8",
|
||||||
|
"@pushrocks/smartunique": "^3.0.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.4",
|
"@gitzone/tsbuild": "^2.1.4",
|
||||||
|
@ -19,12 +19,14 @@ tap.test(`should produce an instance of NginxConfig`, async () => {
|
|||||||
testNginxZone01 = new smartnginx.NginxHost(testSmartNginx, {
|
testNginxZone01 = new smartnginx.NginxHost(testSmartNginx, {
|
||||||
hostName: 'test100.bleu.de',
|
hostName: 'test100.bleu.de',
|
||||||
destination: '192.192.192.191',
|
destination: '192.192.192.191',
|
||||||
|
destinationPort: 3000,
|
||||||
privateKey: 'some private',
|
privateKey: 'some private',
|
||||||
publicKey: 'some public'
|
publicKey: 'some public'
|
||||||
});
|
});
|
||||||
testNginxZone02 = new smartnginx.NginxHost(testSmartNginx, {
|
testNginxZone02 = new smartnginx.NginxHost(testSmartNginx, {
|
||||||
hostName: 'test102.bleu.de',
|
hostName: 'test102.bleu.de',
|
||||||
destination: '192.192.192.192',
|
destination: '192.192.192.192',
|
||||||
|
destinationPort: 3050,
|
||||||
privateKey: 'some private',
|
privateKey: 'some private',
|
||||||
publicKey: 'some public'
|
publicKey: 'some public'
|
||||||
});
|
});
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
export interface IHostConfig {
|
export interface IHostConfig {
|
||||||
hostName: string;
|
hostName: string;
|
||||||
destination: string;
|
destination: string;
|
||||||
|
destinationPort: number;
|
||||||
privateKey: string;
|
privateKey: string;
|
||||||
publicKey: string;
|
publicKey: string;
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ export class NginxHost implements IHostConfig {
|
|||||||
|
|
||||||
public hostName: string; // the host name e.g. domain name
|
public hostName: string; // the host name e.g. domain name
|
||||||
public destination: string;
|
public destination: string;
|
||||||
|
public destinationPort: number;
|
||||||
public configString: string; // the actual host config file as string
|
public configString: string; // the actual host config file as string
|
||||||
public privateKey: string;
|
public privateKey: string;
|
||||||
public publicKey: string;
|
public publicKey: string;
|
||||||
@ -29,7 +30,7 @@ export class NginxHost implements IHostConfig {
|
|||||||
this.smartnginxInstance = smartnginxInstanceArg;
|
this.smartnginxInstance = smartnginxInstanceArg;
|
||||||
this.hostName = optionsArg.hostName;
|
this.hostName = optionsArg.hostName;
|
||||||
this.destination = optionsArg.destination;
|
this.destination = optionsArg.destination;
|
||||||
this.configString = snippets.getHostConfigString(optionsArg.hostName, optionsArg.destination);
|
this.destinationPort = optionsArg.destinationPort;
|
||||||
this.privateKey = optionsArg.privateKey;
|
this.privateKey = optionsArg.privateKey;
|
||||||
this.publicKey = optionsArg.publicKey;
|
this.publicKey = optionsArg.publicKey;
|
||||||
}
|
}
|
||||||
@ -42,7 +43,10 @@ export class NginxHost implements IHostConfig {
|
|||||||
const filePathConfig = plugins.path.join(paths.nginxHostDirPath, `${this.hostName}.conf`);
|
const filePathConfig = plugins.path.join(paths.nginxHostDirPath, `${this.hostName}.conf`);
|
||||||
const filePathPrivate = plugins.path.join(paths.nginxHostDirPath, `${this.hostName}.private.pem`);
|
const filePathPrivate = plugins.path.join(paths.nginxHostDirPath, `${this.hostName}.private.pem`);
|
||||||
const filePathPublic = plugins.path.join(paths.nginxHostDirPath, `${this.hostName}.public.pem`);
|
const filePathPublic = plugins.path.join(paths.nginxHostDirPath, `${this.hostName}.public.pem`);
|
||||||
|
|
||||||
|
|
||||||
// writeConfig
|
// writeConfig
|
||||||
|
this.configString = snippets.getHostConfigString(this.hostName, this.destination, this.destinationPort);
|
||||||
plugins.smartfile.memory.toFsSync(this.configString, filePathConfig);
|
plugins.smartfile.memory.toFsSync(this.configString, filePathConfig);
|
||||||
|
|
||||||
// write ssl
|
// write ssl
|
||||||
|
@ -78,7 +78,8 @@ export class SmartNginx {
|
|||||||
await this.deployedHosts.forEach(async deployedHostArg => {
|
await this.deployedHosts.forEach(async deployedHostArg => {
|
||||||
if (
|
if (
|
||||||
hostCandidateArg.hostName === deployedHostArg.hostName &&
|
hostCandidateArg.hostName === deployedHostArg.hostName &&
|
||||||
hostCandidateArg.destination === deployedHostArg.destination
|
hostCandidateArg.destination === deployedHostArg.destination &&
|
||||||
|
hostCandidateArg.destinationPort === deployedHostArg.destinationPort
|
||||||
) {
|
) {
|
||||||
hostCounter++;
|
hostCounter++;
|
||||||
foundHost = true;
|
foundHost = true;
|
||||||
|
@ -10,5 +10,6 @@ import * as smartpromise from '@pushrocks/smartpromise';
|
|||||||
import * as smartshell from '@pushrocks/smartshell';
|
import * as smartshell from '@pushrocks/smartshell';
|
||||||
import * as smartfile from '@pushrocks/smartfile';
|
import * as smartfile from '@pushrocks/smartfile';
|
||||||
import * as smartstring from '@pushrocks/smartstring';
|
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 };
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import * as plugins from './smartnginx.plugins';
|
import * as plugins from './smartnginx.plugins';
|
||||||
import * as paths from './smartnginx.paths';
|
import * as paths from './smartnginx.paths';
|
||||||
export let getBaseConfigString = () => {
|
export let getBaseConfigString = () => {
|
||||||
let baseConfig = plugins.smartstring.indent.normalize(`
|
const baseConfig = plugins.smartstring.indent.normalize(`
|
||||||
user www-data;
|
user www-data;
|
||||||
worker_processes auto;
|
worker_processes auto;
|
||||||
pid /run/nginx/nginx.pid;
|
pid /run/nginx/nginx.pid;
|
||||||
@ -71,20 +71,11 @@ export let getBaseConfigString = () => {
|
|||||||
return baseConfig;
|
return baseConfig;
|
||||||
};
|
};
|
||||||
|
|
||||||
export let getHostConfigString = (hostNameArg: string, destinationIpArg: string) => {
|
export let getHostConfigString = (hostNameArg: string, destinationIpArg: string, destinationPortArg = 80) => {
|
||||||
let hostConfig = plugins.smartstring.indent.normalize(`
|
const hostConfig = plugins.smartstring.indent.normalize(`
|
||||||
upstream ${hostNameArg} {
|
upstream ${hostNameArg} {
|
||||||
keepalive 100;
|
keepalive 100;
|
||||||
server ${destinationIpArg};
|
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
server {
|
server {
|
||||||
@ -92,16 +83,13 @@ export let getHostConfigString = (hostNameArg: string, destinationIpArg: string)
|
|||||||
server_name ${hostNameArg};
|
server_name ${hostNameArg};
|
||||||
ssl_certificate ${paths.nginxHostDirPath}/${hostNameArg}.public.pem;
|
ssl_certificate ${paths.nginxHostDirPath}/${hostNameArg}.public.pem;
|
||||||
ssl_certificate_key ${paths.nginxHostDirPath}/${hostNameArg}.private.pem;
|
ssl_certificate_key ${paths.nginxHostDirPath}/${hostNameArg}.private.pem;
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
proxy_http_version 1.1;
|
proxy_http_version 1.1;
|
||||||
proxy_set_header Host $http_host;
|
proxy_buffering off;
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
proxy_set_header X-Forwarded-For $remote_addr;
|
||||||
proxy_set_header X-Forwarded-Proto $scheme;
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
proxy_set_header Connection "Keep-Alive";
|
proxy_pass http://${hostNameArg};
|
||||||
proxy_set_header Proxy-Connection "Keep-Alive";
|
|
||||||
proxy_pass http://${hostNameArg};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`);
|
`);
|
||||||
|
Reference in New Issue
Block a user