use vhost naming for nginx config terminology

This commit is contained in:
Girish Ramakrishnan
2022-11-17 08:27:06 +01:00
parent 293b8a0d34
commit 35076b0e93

View File

@@ -448,13 +448,13 @@ async function ensureCertificate(fqdn, domainObject, options, auditSource) {
await safe(eventlog.add(renewal ? eventlog.ACTION_CERTIFICATE_RENEWAL : eventlog.ACTION_CERTIFICATE_NEW, auditSource, { domain: fqdn, errorMessage: renewError?.message || '' }));
}
async function writeDashboardNginxConfig(fqdn, certificatePath) {
assert.strictEqual(typeof fqdn, 'string');
async function writeDashboardNginxConfig(vhost, certificatePath) {
assert.strictEqual(typeof vhost, 'string');
assert.strictEqual(typeof certificatePath, 'object');
const data = {
sourceDir: path.resolve(__dirname, '..'),
vhost: fqdn,
vhost,
hasIPv6: sysinfo.hasIPv6(),
endpoint: 'dashboard',
certFilePath: certificatePath.certFilePath,
@@ -464,7 +464,7 @@ async function writeDashboardNginxConfig(fqdn, certificatePath) {
ocsp: await isOcspEnabled(certificatePath.certFilePath)
};
const nginxConf = ejs.render(NGINX_APPCONFIG_EJS, data);
const nginxConfigFilename = path.join(paths.NGINX_APPCONFIG_DIR, `${fqdn}.conf`);
const nginxConfigFilename = path.join(paths.NGINX_APPCONFIG_DIR, `${vhost}.conf`);
if (!safe.fs.writeFileSync(nginxConfigFilename, nginxConf)) throw new BoxError(BoxError.FS_ERROR, safe.error);
}
@@ -481,15 +481,15 @@ async function writeDashboardConfig(domainObject) {
await reload();
}
async function writeAppNginxConfig(app, fqdn, type, certificatePath) {
async function writeAppNginxConfig(app, vhost, type, certificatePath) {
assert.strictEqual(typeof app, 'object');
assert.strictEqual(typeof fqdn, 'string');
assert.strictEqual(typeof vhost, 'string');
assert.strictEqual(typeof type, 'string');
assert.strictEqual(typeof certificatePath, 'object');
const data = {
sourceDir: path.resolve(__dirname, '..'),
vhost: fqdn,
vhost,
hasIPv6: sysinfo.hasIPv6(),
ip: null,
port: null,
@@ -535,7 +535,7 @@ async function writeAppNginxConfig(app, fqdn, type, certificatePath) {
data.port = app.manifest.httpPort;
} else if (type === apps.LOCATION_TYPE_SECONDARY) {
data.ip = app.containerIp;
const secondaryDomain = app.secondaryDomains.find(sd => sd.fqdn === fqdn);
const secondaryDomain = app.secondaryDomains.find(sd => sd.fqdn === vhost);
data.port = app.manifest.httpPorts[secondaryDomain.environmentVariable].containerPort;
}
} else if (type === apps.LOCATION_TYPE_REDIRECT) {
@@ -545,8 +545,8 @@ async function writeAppNginxConfig(app, fqdn, type, certificatePath) {
}
const nginxConf = ejs.render(NGINX_APPCONFIG_EJS, data);
const filename = path.join(paths.NGINX_APPCONFIG_DIR, `${app.id}-${fqdn.replace('*', '_')}.conf`);
debug(`writeAppNginxConfig: writing config for "${fqdn}" to ${filename} with options ${JSON.stringify(data)}`);
const filename = path.join(paths.NGINX_APPCONFIG_DIR, `${app.id}-${vhost.replace('*', '_')}.conf`);
debug(`writeAppNginxConfig: writing config for "${vhost}" to ${filename} with options ${JSON.stringify(data)}`);
if (!safe.fs.writeFileSync(filename, nginxConf)) {
debug(`Error creating nginx config for "${app.fqdn}" : ${safe.error.message}`);
throw new BoxError(BoxError.FS_ERROR, safe.error);