I am trying to install a certificate with certbot onto my subdomain. It says that I have no server_name directive in my nginx config but I do, and I did nginx -t and it said the config was ok.
This is the command line output from certbot
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator nginx, Installer nginx
No names were found in your configuration files. Please enter in your domain
name(s) (comma and/or space separated) (Enter 'c' to cancel): subdomain.website.com
Attempting to parse the version 1.9.0 renewal configuration file found at /etc/letsencrypt/renewal/website.com.
conf with version 0.40.0 of Certbot. This might not work.
Cert not yet due for renewal
You have an existing certificate that has exactly the same domains or certificate name you requested and isn't close to expiry.
What would you like to do?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: Attempt to reinstall this existing certificate
2: Renew & replace the cert (limit ~5 per 7 days)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 1
Keeping the existing certificate
Could not automatically find a matching server block for subdomain.website.com. Set the `server_name` directive to use the Nginx installer.
IMPORTANT NOTES:
- Unable to install the certificate
- Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/subdomain.website.com/fullchain.pem
Your key file has been saved at:
/etc/letsencrypt/live/subdomain.website.com/privkey.pem
Your cert will expire on 2021-01-01. To obtain a new or tweaked
version of this certificate in the future, simply run certbot again
with the "certonly" option. To non-interactively renew *all* of
your certificates, run "certbot renew"
This is my nginx configuration.
server {
listen 80;
root /var/www/html;
index index.html;
server_name website.com www.website.com;
location / {
try_files $uri =404;
}
error_log /var/log/nginx/website.com/error.log;
}
server {
listen 80;
server_name subdomain.website.com;
location / {
proxy_pass http://localhost:3000;
}
}