diff --git a/slapos/recipe/apache_frontend/__init__.py b/slapos/recipe/apache_frontend/__init__.py index 1dd35e4e854ebc225ced31f7c8a5ee4cfe1fc9c2..622539a3f53eee73bc7b07f18be766e00b518d28 100644 --- a/slapos/recipe/apache_frontend/__init__.py +++ b/slapos/recipe/apache_frontend/__init__.py @@ -470,6 +470,27 @@ class Recipe(BaseSlapRecipe): self._createDirectory(cache_directory_location) self._createDirectory(mod_ssl_cache_location) + # Create "custom" apache configuration file if it does not exist. + # Note : This file won't be erased or changed when slapgrid is ran. + # It can be freely customized by node admin. + custom_apache_configuration_directory = os.path.join( + self.data_root_directory, 'apache-conf.d') + self._createDirectory(custom_apache_configuration_directory) + custom_apache_configuration_file_location = os.path.join( + custom_apache_configuration_directory, 'apache_frontend.custom.conf') + f = open(custom_apache_configuration_file_location, 'a') + f.close() + + # Create backup of custom apache configuration + backup_path = self.createBackupDirectory('custom_apache_conf_backup') + backup_cron = os.path.join(self.cron_d, 'custom_apache_conf_backup') + open(backup_cron, 'w').write( + '''0 0 * * * %(rdiff_backup)s %(source)s %(destination)s'''%dict( + rdiff_backup=self.options['rdiff_backup_binary'], + source=custom_apache_configuration_directory, + destination=backup_path)) + self.path_list.append(backup_cron) + # Create configuration file and rewritemaps apachemap_name = "apachemap.txt" apachemapzope_name = "apachemapzope.txt" @@ -497,6 +518,7 @@ class Recipe(BaseSlapRecipe): apachemapzope_path=os.path.join(self.etc_directory, apachemapzope_name), apache_domain=name, port=port, + custom_apache_conf=custom_apache_configuration_file_location, )) apache_conf_string = self.substituteTemplate( diff --git a/slapos/recipe/apache_frontend/template/apache.conf.in b/slapos/recipe/apache_frontend/template/apache.conf.in index 9614365f91dd9b872b4654acdf509d8f2cc29aef..2ce3229626e055b9729a5a6e006376831d7a248f 100644 --- a/slapos/recipe/apache_frontend/template/apache.conf.in +++ b/slapos/recipe/apache_frontend/template/apache.conf.in @@ -110,3 +110,7 @@ BrowserMatch ^Mozilla/4\.0[678] no-gzip BrowserMatch \bMSIE !no-gzip !gzip-only-text/html # Make sure proxies don't deliver the wrong content Header append Vary User-Agent + +# Include configuration file not operated by slapos. This file won't be erased +# or changed when slapgrid is ran. It can be freely customized by node admin. +Include %(custom_apache_conf)s