Skip to content

Commit

Permalink
Fix bug that stopped nginx from finding new server block for redirect (
Browse files Browse the repository at this point in the history
…#5198)

* fix bug that stopped nginx from finding new server block for redirect

* add regression test
  • Loading branch information
ohemorange authored and bmw committed Oct 20, 2017
1 parent 3c1dafa commit e2ab940
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 4 additions & 1 deletion certbot-nginx/certbot_nginx/configurator.py
Expand Up @@ -266,7 +266,10 @@ def _vhost_from_duplicated_default(self, domain):
self.new_vhost.names = set()

self.new_vhost.names.add(domain)
name_block = [['\n ', 'server_name', ' ', ' '.join(self.new_vhost.names)]]
name_block = [['\n ', 'server_name']]
for name in self.new_vhost.names:
name_block[0].append(' ')
name_block[0].append(name)
self.parser.add_server_directives(self.new_vhost, name_block, replace=True)
return self.new_vhost

Expand Down
7 changes: 7 additions & 0 deletions certbot-nginx/certbot_nginx/tests/configurator_test.py
Expand Up @@ -676,6 +676,13 @@ def test_deploy_no_match_add_redirect(self):
"example/chain.pem",
"example/fullchain.pem")

self.config.deploy_cert(
"nomatch.com",
"example/cert.pem",
"example/key.pem",
"example/chain.pem",
"example/fullchain.pem")

self.config.enhance("www.nomatch.com", "redirect")

self.config.save()
Expand Down

0 comments on commit e2ab940

Please sign in to comment.