Merge pull request #7738 from osirisinferi/nginx-hostname

[nginx] Parse $hostname in `server_name`
This commit is contained in:
schoen
2020-02-06 14:44:03 -08:00
committed by GitHub
5 changed files with 22 additions and 10 deletions
@@ -313,9 +313,6 @@ class NginxConfigurator(common.Installer):
.. todo:: This should maybe return list if no obvious answer
is presented.
.. todo:: The special name "$hostname" corresponds to the machine's
hostname. Currently we just ignore this.
:param str target_name: domain name
:param bool create_if_no_match: If we should create a new vhost from default
when there is no match found. If we can't choose a default, raise a
@@ -598,6 +595,12 @@ class NginxConfigurator(common.Installer):
all_names = set() # type: Set[str]
for vhost in self.parser.get_vhosts():
try:
vhost.names.remove("$hostname")
vhost.names.add(socket.gethostname())
except KeyError:
pass
all_names.update(vhost.names)
for addr in vhost.addrs: