mirror of
https://github.com/certbot/certbot.git
synced 2026-07-28 08:45:22 +02:00
rewrite generic files
This commit is contained in:
@@ -1074,6 +1074,9 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
|
||||
if not self._is_rewrite_engine_on(general_vh):
|
||||
self.parser.add_dir(general_vh.path, "RewriteEngine", "on")
|
||||
|
||||
for name in ssl_vhost.get_names():
|
||||
self.parser.add_dir(general_vh.path, "RewriteCond",
|
||||
["%{SERVER_NAME}", "={0}".format(name), "[OR]"]
|
||||
if self.get_version() >= (2, 3, 9):
|
||||
self.parser.add_dir(general_vh.path, "RewriteRule",
|
||||
constants.REWRITE_HTTPS_ARGS_WITH_END)
|
||||
@@ -1243,6 +1246,10 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
|
||||
for http_vh in candidate_http_vhs:
|
||||
if http_vh.same_server(ssl_vhost):
|
||||
return http_vh
|
||||
# Third filter - if none with same names, return generic
|
||||
for http_vh in candidate_http_vhs:
|
||||
if http_vh.same_server(ssl_vhost, generic=True):
|
||||
return http_vh
|
||||
|
||||
return None
|
||||
|
||||
|
||||
@@ -189,7 +189,7 @@ class VirtualHost(object): # pylint: disable=too-few-public-methods
|
||||
return True
|
||||
return False
|
||||
|
||||
def same_server(self, vhost):
|
||||
def same_server(self, vhost, generic=False):
|
||||
"""Determines if the vhost is the same 'server'.
|
||||
|
||||
Used in redirection - indicates whether or not the two virtual hosts
|
||||
@@ -199,12 +199,17 @@ class VirtualHost(object): # pylint: disable=too-few-public-methods
|
||||
|
||||
"""
|
||||
|
||||
if vhost.get_names() != self.get_names():
|
||||
return False
|
||||
if not generic:
|
||||
if vhost.get_names() != self.get_names():
|
||||
return False
|
||||
|
||||
# If equal and set is not empty... assume same server
|
||||
if self.name is not None or self.aliases:
|
||||
return True
|
||||
# If equal and set is not empty... assume same server
|
||||
if self.name is not None or self.aliases:
|
||||
return True
|
||||
# If we're looking for a generic vhost, don't return one with a ServerName
|
||||
else:
|
||||
if self.name:
|
||||
return False
|
||||
|
||||
# Both sets of names are empty.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user