Commit 22703390 authored by Vincent Pelletier's avatar Vincent Pelletier

apache supports more than one listening port. Support it in recipe too.

parent 7984b871
...@@ -29,61 +29,71 @@ import pkg_resources ...@@ -29,61 +29,71 @@ import pkg_resources
class Recipe(GenericBaseRecipe): class Recipe(GenericBaseRecipe):
def install(self): def install(self):
path_list = [] try:
ip = self.options['ip'] backend_list = self.options['backend-list']
port = self.options['port'] except KeyError:
backend = self.options['backend'] backend_list = [(self.options['port'], self.options['backend'])]
apache_conf = dict()
scheme = self.options['scheme'] scheme = self.options['scheme']
if scheme == 'http': if scheme == 'http':
required_path_list = [] required_path_list = []
apache_conf['ssl_snippet'] = '' ssl_enable = ssl_snippet = ''
elif scheme == 'https': elif scheme == 'https':
key = self.options['key-file'] key = self.options['key-file']
certificate = self.options['cert-file'] certificate = self.options['cert-file']
required_path_list = [key, certificate] required_path_list = [key, certificate]
apache_conf['key'] = key ssl_snippet = self.substituteTemplate(self.getTemplateFilename('snippet.ssl.in'), {
apache_conf['certificate'] = certificate 'key': key,
apache_conf['ssl_session_cache'] = self.options['ssl-session-cache'] 'certificate': certificate,
apache_conf['ssl_snippet'] = pkg_resources.resource_string(__name__, 'ssl_session_cache': self.options['ssl-session-cache'],
'template/snippet.ssl.in') % apache_conf })
if 'ssl-authentication' in self.options and self.optionIsTrue( if 'ssl-authentication' in self.options and self.optionIsTrue(
'ssl-authentication'): 'ssl-authentication'):
apache_conf['ssl_snippet'] += pkg_resources.resource_string(__name__, ssl_snippet += self.substituteTemplate(self.getTemplateFilename('snippet.ssl.ca.in'), {
'template/snippet.ssl.ca.in') % dict( 'ca_certificate': self.options['ssl-authentication-certificate'],
ca_certificate=self.options['ssl-authentication-certificate'], 'ca_crl': self.options['ssl-authentication-crl'],
ca_crl=self.options['ssl-authentication-crl'] })
) ssl_enable = 'SSLEngine on'
else: else:
raise ValueError, "Unsupported scheme %s" % scheme raise ValueError('Unsupported scheme %s' % scheme)
access_control_string = self.options['access-control-string'] ip = self.options['ip']
apache_conf['pid_file'] = self.options['pid-file'] backend_path = self.options.get('backend-path', '/')
apache_conf['lock_file'] = self.options['lock-file'] vhost_template_name = self.getTemplateFilename('vhost.in')
apache_conf['ip'] = ip apache_config_file = self.createFile(
apache_conf['port'] = port self.options['configuration-file'],
apache_conf['server_admin'] = 'admin@' self.substituteTemplate(
apache_conf['error_log'] = self.options['error-log'] self.getTemplateFilename('apache.zope.conf.in'),
apache_conf['access_log'] = self.options['access-log'] {
apache_conf['server_name'] = '%s' % apache_conf['ip'] 'path': '/',
apache_conf['path'] = '/' 'server_admin': 'admin@',
apache_conf['access_control_string'] = access_control_string 'pid_file': self.options['pid-file'],
apache_conf['rewrite_rule'] = "RewriteRule (.*) %s%s$1 [L,P]" % (backend, 'lock_file': self.options['lock-file'],
self.options.get('backend-path', '/')) 'error_log': self.options['error-log'],
apache_conf_string = pkg_resources.resource_string(__name__, 'access_log': self.options['access-log'],
'template/apache.zope.conf.in') % apache_conf 'access_control_string': self.options['access-control-string'],
apache_config_file = self.createFile(self.options['configuration-file'], 'ssl_snippet': ssl_snippet,
apache_conf_string) 'vhosts': ''.join(self.substituteTemplate(vhost_template_name, {
path_list.append(apache_config_file) 'ip': ip,
wrapper = self.createPythonScript(self.options['wrapper'], __name__ + 'port': port,
'.apache.runApache', [ 'backend': backend,
dict( 'backend-path': backend_path,
required_path_list=required_path_list, 'ssl_enable': ssl_enable,
binary=self.options['apache-binary'], }) for (port, backend) in backend_list),
config=apache_config_file },
)
) )
]) return [
path_list.append(wrapper) apache_config_file,
return path_list self.createPythonScript(
self.options['wrapper'],
__name__ + '.apache.runApache',
[
{
'required_path_list': required_path_list,
'binary': self.options['apache-binary'],
'config': apache_config_file,
},
],
),
]
...@@ -22,7 +22,6 @@ LoadModule headers_module modules/mod_headers.so ...@@ -22,7 +22,6 @@ LoadModule headers_module modules/mod_headers.so
# Basic server configuration # Basic server configuration
PidFile "%(pid_file)s" PidFile "%(pid_file)s"
Listen %(ip)s:%(port)s
ServerAdmin %(server_admin)s ServerAdmin %(server_admin)s
TypesConfig conf/mime.types TypesConfig conf/mime.types
AddType application/x-compress .Z AddType application/x-compress .Z
...@@ -63,4 +62,4 @@ CustomLog "%(access_log)s" combined ...@@ -63,4 +62,4 @@ CustomLog "%(access_log)s" combined
# Magic of Zope related rewrite # Magic of Zope related rewrite
RewriteEngine On RewriteEngine On
%(rewrite_rule)s %(vhosts)s
# SSL Configuration
SSLEngine on
SSLCertificateFile %(certificate)s SSLCertificateFile %(certificate)s
SSLCertificateKeyFile %(key)s SSLCertificateKeyFile %(key)s
SSLRandomSeed startup builtin SSLRandomSeed startup builtin
......
Listen %(ip)s:%(port)s
<VirtualHost *:%(port)s>
%(ssl_enable)s
RewriteRule (.*) %(backend)s%(backend-path)s$1 [L,P]
</VirtualHost>
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