diff --git a/install/lib/installer_base.lib.php b/install/lib/installer_base.lib.php
index aa85837ffc1ba96b27b5bd7963090abb0ae68a5d..622674267c21b6f214f3bb3f313031c137788ec3 100644
--- a/install/lib/installer_base.lib.php
+++ b/install/lib/installer_base.lib.php
@@ -1868,7 +1868,11 @@ class installer_base {
 		);
 		foreach ($local_d as $f) {
 			$tpl = new tpl();
-			$tpl->newTemplate("rspamd_${f}.master");
+			if (file_exists($conf['ispconfig_install_dir']."/server/conf-custom/install/rspamd_${f}.master")) {
+				$tpl->newTemplate($conf['ispconfig_install_dir']."/server/conf-custom/install/rspamd_${f}.master");
+			} else {
+				$tpl->newTemplate("rspamd_${f}.master");
+			}
 
 			$tpl->setVar('dkim_path', $mail_config['dkim_path']);
 			$tpl->setVar('rspamd_redis_servers', $mail_config['rspamd_redis_servers']);
@@ -1964,7 +1968,11 @@ class installer_base {
 		unset($server_ini_string);
 
 		$tpl = new tpl();
-		$tpl->newTemplate('rspamd_worker-controller.inc.master');
+		if (file_exists($conf['ispconfig_install_dir']."/server/conf-custom/install/rspamd_worker-controller.inc.master")) {
+			$tpl->newTemplate($conf['ispconfig_install_dir']."/server/conf-custom/install/rspamd_worker-controller.inc.master");
+		} else {
+			$tpl->newTemplate("rspamd_worker-controller.inc.master");
+		}
 		$rspamd_password = $mail_config['rspamd_password'];
 		$crypted_password = trim(exec('rspamadm pw -p ' . escapeshellarg($rspamd_password)));
 		if($crypted_password) {
diff --git a/server/plugins-available/rspamd_plugin.inc.php b/server/plugins-available/rspamd_plugin.inc.php
index 63640d02e68cfe105bea358ee2a32afe799e1388..9d34ac8a36fdd6b14a907881623c949067342121 100644
--- a/server/plugins-available/rspamd_plugin.inc.php
+++ b/server/plugins-available/rspamd_plugin.inc.php
@@ -295,7 +295,11 @@ class rspamd_plugin {
 				$app->load('tpl');
 
 				$tpl = new tpl();
-				$tpl->newTemplate('rspamd_users.inc.conf.master');
+				if (file_exists($conf['rootpath']."/conf-custom/install/rspamd_users.inc.conf.master")) {
+					$tpl->newTemplate($conf['rootpath']."/conf-custom/install/rspamd_users.inc.conf.master");
+				} else {
+					$tpl->newTemplate("rspamd_users.inc.conf.master");
+				}
 
 				$tpl->setVar('record_identifier', 'ispc_' . $type . '_' . $entry_id);
 				$tpl->setVar('priority', $settings_priority);
@@ -443,7 +447,12 @@ class rspamd_plugin {
 					}
 				} else {
 					$tpl = new tpl();
-					$tpl->newTemplate('rspamd_wblist.inc.conf.master');
+					if (file_exists($conf['rootpath']."/conf-custom/install/rspamd_wblist.inc.conf.master")) {
+			                        $tpl->newTemplate($conf['rootpath']."/conf-custom/install/rspamd_wblist.inc.conf.master");
+					} else {
+						$tpl->newTemplate("rspamd_wblist.inc.conf.master");
+					}
+
 					$tpl->setVar('list_scope', ($global_filter ? 'global' : 'spamfilter'));
 					$tpl->setVar('record_id', $record_id);
 					// add 30/40 to priority to avoid collisions and prefer white/blacklists above mailbox/domain spamfilter settings
@@ -521,7 +530,11 @@ class rspamd_plugin {
 		);
 		foreach ($local_d as $f) {
 			$tpl = new tpl();
-			$tpl->newTemplate("rspamd_${f}.master");
+			if (file_exists($conf['rootpath']."/conf-custom/install/rspamd_${f}.master")) {
+				$tpl->newTemplate($conf['rootpath']."/conf-custom/install/rspamd_${f}.master");
+			} else {
+				$tpl->newTemplate("rspamd_${f}.master");
+			}
 
 			$tpl->setVar('dkim_path', $mail_config['dkim_path']);
 			$tpl->setVar('rspamd_redis_servers', $mail_config['rspamd_redis_servers']);