Hello,
I am working on a project as a contractor that was previously worked on by someone else. I'm using Amazon Lightsail with an Ubuntu 16.04.03 instance which I can log onto as root. They actually set up the server using Python Daphne. When they set up the SSL certification, they were using Certbot 0.19.0. This is where it got a bit confusing. In the set of instructions that he gave me for certificate renewal (which is manual), he said to basically run this command
'sudo certbot --authenticator standalone --installer nginx -d prod.thefelixapps.com --pre-hook "service nginx stop" --post-hook "service nginx start"'
and then copy over the new certificates over to the Daphne server/django folder. However, nginx isn't the server being used here, it's Daphne. When I asked him about this, the previous contractor emailed me and said,
I was using nginx just because that was one of the few webservers that certbot worked with at the time. So I ran it and allowed it to copy the certificate files to where nginx would expect them and then just copied the files to where the Python code needed them. Nginx is not used at all and as long as it's directory structure is there this process should be fine. Certbot is more capable now so using the nginx structure might not even be needed anymore.
The last sentence is definitely true. I see from the Certbot installation instructions that they provide an option for unspecified webservers. Since I was running into weird nginx errors that I can't seem to get rid of testing renewal with certbot renew --dry-run that look like this
Cert not due for renewal, but simulating renewal for dry run
Plugins selected: Authenticator standalone, Installer nginx
Running pre-hook command: service nginx stop
Renewing an existing certificate
Performing the following challenges:
http-01 challenge for prod.thefelixapps.com
Waiting for verification...
Cleaning up challenges
nginx: [error] invalid PID number "" in "/run/nginx.pid"
Attempting to renew cert (prod.thefelixapps.com) from /etc/letsencrypt/renewal/prod.thefel
ixapps.com.conf produced an unexpected error: nginx restart failed:
. Skipping.
All renewal attempts failed. The following certs could not be renewed:
/etc/letsencrypt/live/prod.thefelixapps.com/fullchain.pem (failure)
** DRY RUN: simulating 'certbot renew' close to cert expiry
** (The test certificates below have not been saved.)
All renewal attempts failed. The following certs could not be renewed:
/etc/letsencrypt/live/prod.thefelixapps.com/fullchain.pem (failure)
** DRY RUN: simulating 'certbot renew' close to cert expiry
** (The test certificates above have not been saved.)
Running post-hook command: service nginx start
Hook command "service nginx start" returned error code 1
Error output from service:
Job for nginx.service failed because the control process exited with error code. See "syst
emctl status nginx.service" and "journalctl -xe" for details.
1 renew failure(s), 0 parse failure(s)
I figured that it was time to just delete the current SSL certificates, uninstall certbot, and try again. However, I've noticed that there exists an nginx folder of which holds a sites-available and sites-enabled folder with code in it for the domain.
server {
# listen 80;
server_name prod.thefelixapps.com;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
alias /home/felix/felixserver/staticserver/;
autoindex off;
}
location / {
include proxy_params;
proxy_pass http://unix:/home/felix/felix.sock;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/prod.thefelixapps.com/fullchain.pem; # managed by Ce
rtbot
ssl_certificate_key /etc/letsencrypt/live/prod.thefelixapps.com/privkey.pem; # managed by
Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
if ($scheme != "https") {
return 301 https://$host$request_uri;
} # managed by Certbot
}
My question can pretty much sum up to, how can I safely start over without getting mixed up in the previous configuration?
Excuse the weird type setting. I don't know why that's happening.