From 6a46e88f8f828609c0e2423e77f9c82410145a13 Mon Sep 17 00:00:00 2001 From: vipergts450 <60085845+vipergts450@users.noreply.github.com> Date: Thu, 6 May 2021 22:29:21 -0400 Subject: [PATCH] Fix renderLocations to accept more parameters from host Amend renderLocations to pass more host parameters into the custom locations to match the requirements set for the default location. This will apply all parameters set in the UI to all custom locations. --- backend/internal/nginx.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/backend/internal/nginx.js b/backend/internal/nginx.js index 336a462c..39753e5d 100644 --- a/backend/internal/nginx.js +++ b/backend/internal/nginx.js @@ -136,6 +136,8 @@ const internalNginx = { * @returns {Promise} */ renderLocations: (host) => { + + // logger.info('host = ' + JSON.stringify(host, null, 2)); return new Promise((resolve, reject) => { let template; @@ -153,8 +155,13 @@ const internalNginx = { const locationRendering = async () => { for (let i = 0; i < host.locations.length; i++) { - let locationCopy = Object.assign({}, host.locations[i]); - + let locationCopy = Object.assign({}, {access_list_id : host.access_list_id}, {certificate_id : host.certificate_id}, + {ssl_forced : host.ssl_forced}, {caching_enabled : host.caching_enabled}, + {block_exploits : host.block_exploits}, {allow_websocket_upgrade : host.allow_websocket_upgrade}, + {http2_support : host.http2_support}, {hsts_enabled : host.hsts_enabled}, + {hsts_subdomains : host.hsts_subdomains}, {access_list : host.access_list}, + {certificate : host.certificate}, host.locations[i]); + if (locationCopy.forward_host.indexOf('/') > -1) { const splitted = locationCopy.forward_host.split('/'); @@ -162,12 +169,16 @@ const internalNginx = { locationCopy.forward_path = `/${splitted.join('/')}`; } + // logger.info('locationCopy = ' + JSON.stringify(locationCopy, null, 2)); + // eslint-disable-next-line renderedLocations += await renderer.parseAndRender(template, locationCopy); } + }; locationRendering().then(() => resolve(renderedLocations)); + }); }, @@ -183,6 +194,8 @@ const internalNginx = { logger.info('Generating ' + host_type + ' Config:', host); } + // logger.info('host = ' + JSON.stringify(host, null, 2)); + let renderEngine = new Liquid({ root: __dirname + '/../templates/' }); @@ -210,6 +223,7 @@ const internalNginx = { } if (host.locations) { + // logger.info ('host.locations = ' + JSON.stringify(host.locations, null, 2)); origLocations = [].concat(host.locations); locationsPromise = internalNginx.renderLocations(host).then((renderedLocations) => { host.locations = renderedLocations;