documentation icon indicating copy to clipboard operation
documentation copied to clipboard

certbot instructions fail with ssl_certificate error on clean Ubuntu 20.04 LTS

Open brookmiles opened this issue 3 years ago • 0 comments

I followed the installation instructions pretty much to the letter, and the only hitch was the step "Acquiring a SSL certificate" which failed with the following error (actual host name was used, not example.com):

certbot --nginx -d example.com
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Error while running nginx -c /etc/nginx/nginx.conf -t.

nginx: [emerg] no "ssl_certificate" is defined for the "listen ... ssl" directive in /etc/nginx/sites-enabled/mastodon:25
nginx: configuration file /etc/nginx/nginx.conf test failed

The nginx plugin is not working; there may be problems with your existing configuration.
The error was: MisconfigurationError('Error while running nginx -c /etc/nginx/nginx.conf -t.\n\nnginx: [emerg] no "ssl_certificate" is defined for the "listen ... ssl" directive in /etc/nginx/sites-enabled/mastodon:25\nnginx: configuration file /etc/nginx/nginx.conf test failed\n')

I was able to pass this step by following these instructions:

This seems like a more complicated solution than is necessary. I just recently migrated to a new Ubuntu 20.04 server and similarly had issues with the instructions. A simpler way to resolve it is to simply run certbot in --standalone mode before (re)loading nginx:

  1. ~install python3-certbot-nginx instead of python-certbot-nginx~ (docs already updated)
  2. Stop nginx (systemctl stop nginx) before running certbot (otherwise --standalone can't access ports 80/443)
  3. uncomment the certificate paths in the nginx.conf file and replace 'example.com' with the real domain
  4. run certbot with certonly --standalone (certbot certonly --standalone -d example.com)
  5. Restart nginx: systemctl start nginx

Originally posted by @hughrun in https://github.com/mastodon/documentation/issues/826#issuecomment-827558844

brookmiles avatar May 01 '22 01:05 brookmiles