Implement 'path' parameter for Zope slave frontends.

Allow to define paths that should be swallowed, e.g '/erp5/web_site_module/foo'.
parent 47d200d4
...@@ -69,6 +69,7 @@ class Recipe(BaseSlapRecipe): ...@@ -69,6 +69,7 @@ class Recipe(BaseSlapRecipe):
rewrite_rule_list = [] rewrite_rule_list = []
rewrite_rule_zope_list = [] rewrite_rule_zope_list = []
rewrite_rule_zope_path_list = []
slave_dict = {} slave_dict = {}
service_dict = {} service_dict = {}
...@@ -118,6 +119,9 @@ class Recipe(BaseSlapRecipe): ...@@ -118,6 +119,9 @@ class Recipe(BaseSlapRecipe):
# RewriteMap for Zope Virtual Host Monster websites. # RewriteMap for Zope Virtual Host Monster websites.
if slave_instance.get("type", "").lower() in ['zope']: if slave_instance.get("type", "").lower() in ['zope']:
rewrite_rule_zope_list.append(rewrite_rule) rewrite_rule_zope_list.append(rewrite_rule)
# For Zope, we have another dict containing the path e.g '/erp5/...
rewrite_rule_path = "%s %s" % (domain, slave_instance.get('path', ''))
rewrite_rule_zope_path_list.append(rewrite_rule_path)
else: else:
rewrite_rule_list.append(rewrite_rule) rewrite_rule_list.append(rewrite_rule)
...@@ -152,6 +156,7 @@ class Recipe(BaseSlapRecipe): ...@@ -152,6 +156,7 @@ class Recipe(BaseSlapRecipe):
name=frontend_domain_name, name=frontend_domain_name,
rewrite_rule_list=rewrite_rule_list, rewrite_rule_list=rewrite_rule_list,
rewrite_rule_zope_list=rewrite_rule_zope_list, rewrite_rule_zope_list=rewrite_rule_zope_list,
rewrite_rule_zope_path_list=rewrite_rule_zope_path_list,
key=key, certificate=certificate) key=key, certificate=certificate)
# Send connection informations about each slave # Send connection informations about each slave
...@@ -475,8 +480,13 @@ class Recipe(BaseSlapRecipe): ...@@ -475,8 +480,13 @@ class Recipe(BaseSlapRecipe):
def installFrontendApache(self, ip_list, key, certificate, name, def installFrontendApache(self, ip_list, key, certificate, name,
port=4443, plain_http_port=8080, port=4443, plain_http_port=8080,
rewrite_rule_list=[], rewrite_rule_zope_list=[], rewrite_rule_list=[],
rewrite_rule_zope_list=[],
rewrite_rule_zope_path_list=None,
access_control_string=None): access_control_string=None):
if rewrite_rule_zope_path_list is None:
rewrite_rule_zope_path_list = []
# Create htdocs, populate it with default 404 document # Create htdocs, populate it with default 404 document
htdocs_location = os.path.join(self.data_root_directory, 'htdocs') htdocs_location = os.path.join(self.data_root_directory, 'htdocs')
self._createDirectory(htdocs_location) self._createDirectory(htdocs_location)
...@@ -517,9 +527,14 @@ class Recipe(BaseSlapRecipe): ...@@ -517,9 +527,14 @@ class Recipe(BaseSlapRecipe):
# Create configuration file and rewritemaps # Create configuration file and rewritemaps
apachemap_name = "apachemap.txt" apachemap_name = "apachemap.txt"
apachemapzope_name = "apachemapzope.txt" apachemapzope_name = "apachemapzope.txt"
apachemapzopepath_name = "apachemapzopepath.txt"
self.createConfigurationFile(apachemap_name, "\n".join(rewrite_rule_list)) self.createConfigurationFile(apachemap_name, "\n".join(rewrite_rule_list))
self.createConfigurationFile(apachemapzope_name, self.createConfigurationFile(apachemapzope_name,
"\n".join(rewrite_rule_zope_list)) "\n".join(rewrite_rule_zope_list))
self.createConfigurationFile(apachemapzopepath_name,
"\n".join(rewrite_rule_zope_path_list))
apache_conf = self._getApacheConfigurationDict(name, ip_list, port) apache_conf = self._getApacheConfigurationDict(name, ip_list, port)
apache_conf['ssl_snippet'] = self.substituteTemplate( apache_conf['ssl_snippet'] = self.substituteTemplate(
self.getTemplateFilename('apache.ssl-snippet.conf.in'), self.getTemplateFilename('apache.ssl-snippet.conf.in'),
...@@ -543,6 +558,7 @@ class Recipe(BaseSlapRecipe): ...@@ -543,6 +558,7 @@ class Recipe(BaseSlapRecipe):
path_enable=path, path_enable=path,
apachemap_path=os.path.join(self.etc_directory, apachemap_name), apachemap_path=os.path.join(self.etc_directory, apachemap_name),
apachemapzope_path=os.path.join(self.etc_directory, apachemapzope_name), apachemapzope_path=os.path.join(self.etc_directory, apachemapzope_name),
apachemapzopepath_path=os.path.join(self.etc_directory, apachemapzopepath_name),
apache_domain=name, apache_domain=name,
https_port=port, https_port=port,
plain_http_port=plain_http_port, plain_http_port=plain_http_port,
......
...@@ -100,15 +100,20 @@ Header append Vary User-Agent ...@@ -100,15 +100,20 @@ Header append Vary User-Agent
ProxyTimeout 600 ProxyTimeout 600
RewriteEngine On RewriteEngine On
# Define the two rewritemaps : one for zope, one generic # Define the two RewriteMaps (key -> value store): one for Zope, one generic
# containing: rewritten URL -> original URL (a.k.a VirtualHostBase in Zope)
RewriteMap apachemapzope txt:%(apachemapzope_path)s RewriteMap apachemapzope txt:%(apachemapzope_path)s
RewriteMap apachemapgeneric txt:%(apachemap_path)s RewriteMap apachemapgeneric txt:%(apachemap_path)s
# Define another RewriteMap for Zope, containing:
# rewritten URL -> VirtualHostRoot
RewriteMap apachemapzopepath txt:%(apachemapzopepath_path)s
# First, we check if we have a zope backend server # First, we check if we have a zope backend server
# If so, let's use Virtual Host Daemon rewrite # If so, let's use Virtual Host Daemon rewrite
RewriteCond ${apachemapzope:%%{SERVER_NAME}} >"" RewriteCond ${apachemapzope:%%{SERVER_NAME}} >""
# We suppose that Apache listens to 443 (even indirectly thanks to things like iptables) # We suppose that Apache listens to 443 (even indirectly thanks to things like iptables)
RewriteRule ^/(.*)$ ${apachemapzope:%%{SERVER_NAME}}/VirtualHostBase/https/%%{SERVER_NAME}:443/VirtualHostRoot/$1 [L,P] RewriteRule ^/(.*)$ ${apachemapzope:%%{SERVER_NAME}}/VirtualHostBase/https/%%{SERVER_NAME}:443/${apachemapzopepath:%%{SERVER_NAME}}/VirtualHostRoot/$1 [L,P]
# If we have generic backend server, let's rewrite without virtual host daemon # If we have generic backend server, let's rewrite without virtual host daemon
RewriteCond ${apachemapgeneric:%%{SERVER_NAME}} >"" RewriteCond ${apachemapgeneric:%%{SERVER_NAME}} >""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment