diff --git a/src/constants.js b/src/constants.js index 812386305..92f7b0713 100644 --- a/src/constants.js +++ b/src/constants.js @@ -20,6 +20,7 @@ exports = module.exports = { ADMIN_NAME: 'Settings', NGINX_ADMIN_CONFIG_FILE_NAME: 'admin.conf', + NGINX_DEFAULT_CONFIG_FILE_NAME: 'default.conf', GHOST_USER_FILE: '/tmp/cloudron_ghost.json', diff --git a/src/reverseproxy.js b/src/reverseproxy.js index 17393eb10..8f0154938 100644 --- a/src/reverseproxy.js +++ b/src/reverseproxy.js @@ -558,8 +558,10 @@ function renewAll(auditSource, callback) { } function removeAppConfigs() { - for (var appConfigFile of fs.readdirSync(paths.NGINX_APPCONFIG_DIR)) { - fs.unlinkSync(path.join(paths.NGINX_APPCONFIG_DIR, appConfigFile)); + for (let appConfigFile of fs.readdirSync(paths.NGINX_APPCONFIG_DIR)) { + if (appConfigFile !== constants.NGINX_DEFAULT_CONFIG_FILE_NAME && appConfigFile !== constants.NGINX_ADMIN_CONFIG_FILE_NAME) { + fs.unlinkSync(path.join(paths.NGINX_APPCONFIG_DIR, appConfigFile)); + } } } @@ -577,7 +579,7 @@ function configureDefaultServer(callback) { safe.child_process.execSync(certCommand); } - writeAdminConfig({ certFilePath, keyFilePath }, 'default.conf', '', function (error) { + writeAdminConfig({ certFilePath, keyFilePath }, constants.NGINX_DEFAULT_CONFIG_FILE_NAME, '', function (error) { if (error) return callback(error); debug('configureDefaultServer: done');