diff --git a/package-lock.json b/package-lock.json index 6dfe864..60d5f39 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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", diff --git a/package.json b/package.json index 668415e..cef3345 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/ts/smartnginx.plugins.ts b/ts/smartnginx.plugins.ts index 182f326..d841c80 100644 --- a/ts/smartnginx.plugins.ts +++ b/ts/smartnginx.plugins.ts @@ -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 }; diff --git a/ts/smartnginx.snippets.ts b/ts/smartnginx.snippets.ts index e8769f8..d70c252 100644 --- a/ts/smartnginx.snippets.ts +++ b/ts/smartnginx.snippets.ts @@ -72,7 +72,12 @@ export let getBaseConfigString = () => { }; export let getHostConfigString = (hostNameArg: string, destinationIpArg: string, destinationPortArg = 80) => { - const hostConfig = plugins.smartstring.indent.normalize(` + let uniqueString = plugins.smartunique.shortId() + const hostConfig = plugins.smartstring.indent.normalize(` + upstream ${uniqueString} { + keepalive 100; + server ${destinationIpArg}:${destinationPortArg}; + } server { # The keepalive parameter sets the maximum number of idle keepalive connections @@ -84,19 +89,18 @@ export let getHostConfigString = (hostNameArg: string, destinationIpArg: string, } server { - listen *:443 ssl http2; + listen *:443 ssl; server_name ${hostNameArg}; ssl_certificate ${paths.nginxHostDirPath}/${hostNameArg}.public.pem; ssl_certificate_key ${paths.nginxHostDirPath}/${hostNameArg}.private.pem; location / { - http2_push_preload on; proxy_http_version 1.1; proxy_buffering off; 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://${destinationIpArg}:${destinationPortArg}; + proxy_pass http://${uniqueString}; } } `);