From 22e8961c8044efc3f36a00a0c463738e427a4de5 Mon Sep 17 00:00:00 2001 From: Jamie Curnow Date: Wed, 8 May 2019 15:33:54 +1000 Subject: [PATCH] Fixes #104 - allow using / location in custom location --- src/backend/internal/nginx.js | 10 +++++++++- src/backend/internal/proxy-host.js | 10 +++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/backend/internal/nginx.js b/src/backend/internal/nginx.js index 556e9fd..21fdbc0 100644 --- a/src/backend/internal/nginx.js +++ b/src/backend/internal/nginx.js @@ -162,7 +162,7 @@ const internalNginx = { renderedLocations += await renderer.parseAndRender(template, locationCopy); } - } + }; locationRendering().then(() => resolve(renderedLocations)); }); @@ -211,6 +211,14 @@ const internalNginx = { locationsPromise = internalNginx.renderLocations(host).then((renderedLocations) => { host.locations = renderedLocations; }); + + // Allow someone who is using / custom location path to use it, and skip the default / location + _.map(host.locations, (location) => { + if (location.path === '/') { + host.use_default_location = false; + } + }); + } else { locationsPromise = Promise.resolve(); } diff --git a/src/backend/internal/proxy-host.js b/src/backend/internal/proxy-host.js index 9f1d9be..c8a75ff 100644 --- a/src/backend/internal/proxy-host.js +++ b/src/backend/internal/proxy-host.js @@ -25,7 +25,7 @@ const internalProxyHost = { } return access.can('proxy_hosts:create', data) - .then(access_data => { + .then(() => { // Get a list of the domain names and check each of them against existing records let domain_name_check_promises = []; @@ -52,7 +52,7 @@ const internalProxyHost = { .omit(omissions()) .insertAndFetch(data); }) - .then(row => { + .then((row) => { if (create_certificate) { return internalCertificate.createQuickCertificate(access, data) .then(cert => { @@ -69,21 +69,21 @@ const internalProxyHost = { return row; } }) - .then(row => { + .then((row) => { // re-fetch with cert return internalProxyHost.get(access, { id: row.id, expand: ['certificate', 'owner', 'access_list'] }); }) - .then(row => { + .then((row) => { // Configure nginx return internalNginx.configure(proxyHostModel, 'proxy_host', row) .then(() => { return row; }); }) - .then(row => { + .then((row) => { // Audit log data.meta = _.assign({}, data.meta || {}, row.meta);