I need to change the domain on my server, which I've been using certbot to get certificates for successfully. I need to switch it to a different domain though. I did not set it up initially so I have no idea how it was done, and can't figure out how to look at the current configuration.

Every answer I've found says I need to refer to the 'webroot' directory, but I'm not sure which that is exactly. It also says the requested nginx plugin does not appear to be installed so I don't think I'm doing it right if that's not how it was done initially.

Ubuntu 16.4 + nginx

edit: after installing the nginx problem, I got a new cert, but it's pointing to the wrong webroot (which is what I was trying to lookup but it's not in the config file)


You can learn about your existing certificates by checking out the old domain's .conf file in /etc/letsencrypt/renewal/ or by doing sudo certbot certificates

If you have changed domain name you can just install the nginx plugin

sudo apt install python-certbot-nginx

obtain a new certificate with

sudo certbot -d [newdomain.tld] --nginx

Afterwards you can check if there are any old, no longer needed certificates configured with

sudo certbot certificates

You will likely find an entry there for the cert with your old domain name. Remove that with

sudo certbot delete

and interactively pick which old ones to delete. This is important so that later you can just issue sudo certbot renew and not get errors due to the no longer relevant domain failing to authorize.

Restart nginx and you are done.

New contributor
Centurion is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • Welcome to Server Fault! This is a great first answer. Checking the configuration file will definitely tell you how the certificate was obtained, though it doesn't give you the exact command line that was used. It is enough information to reconstruct it though. – Michael Hampton Feb 10 at 2:47
  • So this worked I think, but it's not going to the right webroot (which is what I was afraid of) and now my site just says "Welcome to nginx!" – stackers Feb 10 at 18:10
  • Examine /etc/nginx/conf.d and see what .conf files are listed there. – Centurion Feb 11 at 20:33

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.