Skip to content

Commit 6a46e88

Browse files
authored
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.
1 parent e4e94d5 commit 6a46e88

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

backend/internal/nginx.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ const internalNginx = {
136136
* @returns {Promise}
137137
*/
138138
renderLocations: (host) => {
139+
140+
// logger.info('host = ' + JSON.stringify(host, null, 2));
139141
return new Promise((resolve, reject) => {
140142
let template;
141143

@@ -153,21 +155,30 @@ const internalNginx = {
153155

154156
const locationRendering = async () => {
155157
for (let i = 0; i < host.locations.length; i++) {
156-
let locationCopy = Object.assign({}, host.locations[i]);
157-
158+
let locationCopy = Object.assign({}, {access_list_id : host.access_list_id}, {certificate_id : host.certificate_id},
159+
{ssl_forced : host.ssl_forced}, {caching_enabled : host.caching_enabled},
160+
{block_exploits : host.block_exploits}, {allow_websocket_upgrade : host.allow_websocket_upgrade},
161+
{http2_support : host.http2_support}, {hsts_enabled : host.hsts_enabled},
162+
{hsts_subdomains : host.hsts_subdomains}, {access_list : host.access_list},
163+
{certificate : host.certificate}, host.locations[i]);
164+
158165
if (locationCopy.forward_host.indexOf('/') > -1) {
159166
const splitted = locationCopy.forward_host.split('/');
160167

161168
locationCopy.forward_host = splitted.shift();
162169
locationCopy.forward_path = `/${splitted.join('/')}`;
163170
}
164171

172+
// logger.info('locationCopy = ' + JSON.stringify(locationCopy, null, 2));
173+
165174
// eslint-disable-next-line
166175
renderedLocations += await renderer.parseAndRender(template, locationCopy);
167176
}
177+
168178
};
169179

170180
locationRendering().then(() => resolve(renderedLocations));
181+
171182
});
172183
},
173184

@@ -183,6 +194,8 @@ const internalNginx = {
183194
logger.info('Generating ' + host_type + ' Config:', host);
184195
}
185196

197+
// logger.info('host = ' + JSON.stringify(host, null, 2));
198+
186199
let renderEngine = new Liquid({
187200
root: __dirname + '/../templates/'
188201
});
@@ -210,6 +223,7 @@ const internalNginx = {
210223
}
211224

212225
if (host.locations) {
226+
// logger.info ('host.locations = ' + JSON.stringify(host.locations, null, 2));
213227
origLocations = [].concat(host.locations);
214228
locationsPromise = internalNginx.renderLocations(host).then((renderedLocations) => {
215229
host.locations = renderedLocations;

0 commit comments

Comments
 (0)