reverseproxy: move dashboard config to subdir as well

This commit is contained in:
Girish Ramakrishnan
2022-11-17 15:49:59 +01:00
parent 641752a222
commit 00771d8197
3 changed files with 7 additions and 6 deletions

View File

@@ -423,7 +423,7 @@ async function writeDashboardNginxConfig(vhost, certificatePath) {
ocsp: await isOcspEnabled(certificatePath.certFilePath)
};
const nginxConf = ejs.render(NGINX_APPCONFIG_EJS, data);
const nginxConfigFilename = path.join(paths.NGINX_APPCONFIG_DIR, `${vhost}.conf`);
const nginxConfigFilename = path.join(paths.NGINX_APPCONFIG_DIR, `dashboard/${vhost}.conf`);
if (!safe.fs.writeFileSync(nginxConfigFilename, nginxConf)) throw new BoxError(BoxError.FS_ERROR, safe.error);
}
@@ -705,16 +705,17 @@ async function checkCerts(auditSource, progressCallback) {
}
function removeAppConfigs() {
const dashboardConfigFilename = `${settings.dashboardFqdn()}.conf`;
debug('removeAppConfigs: removing app nginx configs');
// remove all configs which are not the default or current dashboard
for (const entry of fs.readdirSync(paths.NGINX_APPCONFIG_DIR, { withFileTypes: true })) {
if (entry.isDirectory() && entry.name === 'dashboard') continue;
if (entry.isFile() && entry.name === constants.NGINX_DEFAULT_CONFIG_FILE_NAME) continue;
const fullPath = path.join(paths.NGINX_APPCONFIG_DIR, entry.name);
if (entry.isDirectory()) {
fs.rmSync(fullPath, { recursive: true, force: true });
} else if (entry.isFile() && entry.name !== constants.NGINX_DEFAULT_CONFIG_FILE_NAME && entry.name !== dashboardConfigFilename) {
} else if (entry.isFile()) {
fs.unlinkSync(fullPath);
}
}