-
-
Notifications
You must be signed in to change notification settings - Fork 988
Description
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')
[Update Nov. 17 2022]
I was originally able to pass this step by following these instructions:
posted by @hughrun in #826 (comment)
But there's an even easier way, which also ensures that renewal will work correctly. As has been pointed out, using --standalone at the beginning will cause renewal to fail later because nginx will be running.
We want nginx to be running, but without the mastodon config loaded.
The best time to do this is before you copy the nginx configuration template and restart nginx, but if you're reading this, maybe you've already done that. Remove the link /etc/nginx/sites-enabled/mastodon to disable the mastodon config, and reload nginx.
By running certbot in certonly mode, we can use the nginx mode, renewals will work, and certbot won't mangle your config file.
- Run
certbot certonly --nginx -d example.com - Copy (or re-enable) the configuration template for nginx per the instructions
- Uncomment the
ssl_certificateandssl_certificate_keylines in/etc/nginx/sites-enabled/mastodon - run
nginx -tto test the config, andsystemctl reload nginxto reload it