## My operating system is (include version):
Ubuntu 14.04.5 LTS
Certbot 0.14.2ā¦
## I installed Certbot with (certbot-auto, OS package manager, pip, etc):
OS package manager from PPA certbot/certbot
## I ran this command and it produced this output:
``` bash
certbot renew
```
```bash
-------------------------------------------------------------------------------
Processing /etc/letsencrypt/renewal/proof.ace.bigroominternet.co.uk.conf
-------------------------------------------------------------------------------
Cert is due for renewal, auto-renewing...
Renewing an existing certificate
Performing the following challenges:
tls-sni-01 challenge for proof.ace.bigroominternet.co.uk
tls-sni-01 challenge for 1.ace.bigroominternet.co.uk
tls-sni-01 challenge for 2.ace.bigroominternet.co.uk
tls-sni-01 challenge for 3.ace.bigroominternet.co.uk
tls-sni-01 challenge for 4.ace.bigroominternet.co.uk
tls-sni-01 challenge for 5.ace.bigroominternet.co.uk
tls-sni-01 challenge for 6.ace.bigroominternet.co.uk
tls-sni-01 challenge for 7.ace.bigroominternet.co.uk
tls-sni-01 challenge for 8.ace.bigroominternet.co.uk
tls-sni-01 challenge for 9.ace.bigroominternet.co.uk
Cleaning up challenges
Attempting to renew cert from /etc/letsencrypt/renewal/proof.ace.bigroominternet.co.uk.conf produced an unexpected error: Cannot find a VirtualHost matching domain 1.ace.bigroominternet.co.uk.. Skipping.
```
## Certbot's behavior differed from what I expected because:
It should have matched and renewed. As you can see I use a regular expression for my virtual host servername.
## Here is a Certbot log showing the issue (if available):
```
2017-07-14 09:31:27,549:DEBUG:acme.client:Storing nonce: F90VgH0lY-qBYJht5yp6okoZoH9bVA3GRuKmBzrc6Yo
2017-07-14 09:31:27,550:INFO:certbot.auth_handler:Performing the following challenges:
2017-07-14 09:31:27,550:INFO:certbot.auth_handler:tls-sni-01 challenge for proof.ace.bigroominternet.co.uk
2017-07-14 09:31:27,551:INFO:certbot.auth_handler:tls-sni-01 challenge for 1.ace.bigroominternet.co.uk
2017-07-14 09:31:27,551:INFO:certbot.auth_handler:tls-sni-01 challenge for 2.ace.bigroominternet.co.uk
2017-07-14 09:31:27,552:INFO:certbot.auth_handler:tls-sni-01 challenge for 3.ace.bigroominternet.co.uk
2017-07-14 09:31:27,553:INFO:certbot.auth_handler:tls-sni-01 challenge for 4.ace.bigroominternet.co.uk
2017-07-14 09:31:27,553:INFO:certbot.auth_handler:tls-sni-01 challenge for 5.ace.bigroominternet.co.uk
2017-07-14 09:31:27,553:INFO:certbot.auth_handler:tls-sni-01 challenge for 6.ace.bigroominternet.co.uk
2017-07-14 09:31:27,553:INFO:certbot.auth_handler:tls-sni-01 challenge for 7.ace.bigroominternet.co.uk
2017-07-14 09:31:27,553:INFO:certbot.auth_handler:tls-sni-01 challenge for 8.ace.bigroominternet.co.uk
2017-07-14 09:31:27,553:INFO:certbot.auth_handler:tls-sni-01 challenge for 9.ace.bigroominternet.co.uk
2017-07-14 09:31:27,835:DEBUG:certbot.error_handler:Encountered exception:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/certbot/auth_handler.py", line 115, in _solve_challenges
resp = self.auth.perform(self.achalls)
File "/usr/lib/python2.7/dist-packages/certbot_nginx/configurator.py", line 805, in perform
sni_response = chall_doer.perform()
File "/usr/lib/python2.7/dist-packages/certbot_nginx/tls_sni_01.py", line 55, in perform
vhost = self.configurator.choose_vhost(achall.domain)
File "/usr/lib/python2.7/dist-packages/certbot_nginx/configurator.py", line 243, in choose_vhost
"Cannot find a VirtualHost matching domain %s." % (target_name))
MisconfigurationError: Cannot find a VirtualHost matching domain 1.ace.bigroominternet.co.uk.
2017-07-14 09:31:27,835:DEBUG:certbot.error_handler:Calling registered functions
2017-07-14 09:31:27,835:INFO:certbot.auth_handler:Cleaning up challenges
2017-07-14 09:31:28,358:DEBUG:certbot_nginx.parser:Could not parse file: /etc/nginx/sites-enabled/default due to Expected "#" (at char 0), (line:1, col:1)
2017-07-14 09:31:29,742:WARNING:certbot.renewal:Attempting to renew cert from /etc/letsencrypt/renewal/proof.ace.bigroominternet.co.uk.conf produced an unexpected error: Cannot find a VirtualHost matching domain 1.ace.bigroominternet.co.uk.. Skipping.
2017-07-14 09:31:29,743:DEBUG:certbot.renewal:Traceback was:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/certbot/renewal.py", line 418, in handle_renewal_request
main.renew_cert(lineage_config, plugins, renewal_candidate)
File "/usr/lib/python2.7/dist-packages/certbot/main.py", line 640, in renew_cert
_get_and_save_cert(le_client, config, lineage=lineage)
File "/usr/lib/python2.7/dist-packages/certbot/main.py", line 77, in _get_and_save_cert
renewal.renew_cert(config, domains, le_client, lineage)
File "/usr/lib/python2.7/dist-packages/certbot/renewal.py", line 296, in renew_cert
new_certr, new_chain, new_key, _ = le_client.obtain_certificate(domains)
File "/usr/lib/python2.7/dist-packages/certbot/client.py", line 313, in obtain_certificate
self.config.allow_subset_of_names)
File "/usr/lib/python2.7/dist-packages/certbot/auth_handler.py", line 74, in get_authorizations
resp = self._solve_challenges()
File "/usr/lib/python2.7/dist-packages/certbot/auth_handler.py", line 115, in _solve_challenges
resp = self.auth.perform(self.achalls)
File "/usr/lib/python2.7/dist-packages/certbot_nginx/configurator.py", line 805, in perform
sni_response = chall_doer.perform()
File "/usr/lib/python2.7/dist-packages/certbot_nginx/tls_sni_01.py", line 55, in perform
vhost = self.configurator.choose_vhost(achall.domain)
File "/usr/lib/python2.7/dist-packages/certbot_nginx/configurator.py", line 243, in choose_vhost
"Cannot find a VirtualHost matching domain %s." % (target_name))
MisconfigurationError: Cannot find a VirtualHost matching domain 1.ace.bigroominternet.co.uk.
```
## Here is the relevant nginx server block or Apache virtualhost for the domain I am configuring:
```
server {
server_name ~^(?<sname>.+?).ace.bigroominternet.co.uk$;
root /var/www/acemedia/$sname/public;
error_log ../error.log;
error_page 500 501 502 503 504 $document_root/whoops.html;
charset UTF-8;
index index.php index.html;
client_max_body_size 60m;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ /\.well-known\/acme-challenge {
allow all;
}
location = /robots.txt { access_log off; log_not_found off; }
location = /humans.txt { access_log off; log_not_found off; }
location = /favicon.ico { access_log off; log_not_found off; }
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php/php5.6-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_read_timeout 1800s;
}
location ~ /\. {
access_log off;
log_not_found off;
deny all;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/proof.ace.bigroominternet.co.uk/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/proof.ace.bigroominternet.co.uk/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
}
```