ServerHandbook live check: run log ------------------------------------------------------------------------------ Article https://serverhandbook.com/kb/lets-encrypt-nginx-ubuntu-24-04 Check scripts/live/checks/lets-encrypt-nginx-ubuntu-24-04.mjs (sha256 78883e573f2e69dd997a1c5afa1a47ecd01f7229af4cb62df205a5dbc619b770) Ran at 2026-11-12T06:11:35Z (311 s) Result PASS, all 39 claims held Tested on System Ubuntu 24.04.4 LTS Kernel 6.8.0-117-generic Package nginx 1.24.0-2ubuntu7.19 Package certbot 2.9.0-1 Package python3-certbot-nginx 2.9.0-1 Package python3-acme 2.9.0-1 Package ufw 0.36.2-6 Setup A fresh Ubuntu 24.04 cloud server from a hosting provider (its stock image, a public IPv4 address), with a domain and its www name pointed at it, ufw on and Nginx installed as the earlier articles leave it; reached over SSH as a sudo user. The certificate is a real one from Let’s Encrypt, and HTTPS was checked from another network. Every version above was read from the server at run time. Passwords used on the throwaway test server are shown as [password]. How we test: https://serverhandbook.com/how-we-test ------------------------------------------------------------------------------ Claims (39), each with what the run saw ------------------------------------------------------------------------------ 1. ok a bare Ubuntu 24.04 server box (web-server) starts 2. ok (setup) ufw on with OpenSSH and Nginx Full allowed, Nginx running, as after the earlier articles | Status: active | | To Action From | -- ------ ---- | OpenSSH ALLOW Anywhere | Nginx Full ALLOW Anywhere | OpenSSH (v6) ALLOW Anywhere (v6) | Nginx Full (v6) ALLOW Anywhere (v6) 3. ok dig prints the server’s address for both names | 203.0.113.10 | 203.0.113.10 4. ok tee prints the page it wrote |

example.com works

5. ok the server block is written (tee prints nothing with > /dev/null) 6. ok nginx -t is successful with the new server block | nginx: the configuration file /etc/nginx/nginx.conf syntax is ok | nginx: configuration file /etc/nginx/nginx.conf test is successful 7. ok the domain serves the new page over HTTP |

example.com works

8. ok (from another network) http://example.com and www answer 200 9. ok apt installs certbot 2.9.0 and its Nginx plugin from Ubuntu’s repository | eb ... | Unpacking python3-parsedatetime (2.6-3) ... | Selecting previously unselected package python3-certbot. | Preparing to unpack .../5-python3-certbot_2.9.0-1_all.deb ... | Unpacking python3-certbot (2.9.0-1) ... | Selecting previously unselected package certbot. | Preparing to unpack .../6-certbot_2.9.0-1_all.deb ... | Unpacking certbot (2.9.0-1) ... | Selecting previously unselected package python3-certbot-nginx. | Preparing to unpack .../7-python3-certbot-nginx_2.9.0-1_all.deb ... | Unpacking python3-certbot-nginx (2.9.0-1) ... | Selecting previously unselected package python3-icu. | Preparing to unpack .../8-python3-icu_2.12-1build2_amd64.deb ... | Unpacking python3-icu (2.12-1build2) ... | Setting up python3-configargparse (1.7-1) ... | Setting up python3-parsedatetime (2.6-3) ... | Setting up python3-icu (2.12-1build2) ... | Setting up python3-josepy (1.14.0-1) ... | Setting up python3-rfc3339 (1.1-4) ... | Setting up python3-acme (2.9.0-1) ... | Setting up python3-certbot (2.9.0-1) ... | Setting up certbot (2.9.0-1) ... | Created symlink /etc/systemd/system/timers.target.wants/certbot.timer → /usr/lib/systemd/system/certbot.timer. | Setting up python3-certbot-nginx (2.9.0-1) ... | Processing triggers for man-db (2.12.0-4build2) ... | | Scanning processes... | Scanning linux images... | | Running kernel seems to be up-to-date. | | No services need to be restarted. | | No containers need to be restarted. | | No user sessions are running outdated binaries. | | No VM guests are running outdated hypervisor (qemu) binaries on this host. 10. ok certbot --version: "certbot 2.9.0" | certbot 2.9.0 11. ok (the package already turned on certbot.timer, before any certificate exists) | enabled | active 12. ok certbot asks for an email, the Terms of Service (Y) and the EFF mailing list (N) | Saving debug log to /var/log/letsencrypt/letsencrypt.log | Enter email address (used for urgent renewal and security notices) | (Enter 'c' to cancel): admin@example.com | | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | Please read the Terms of Service at | https://letsencrypt.org/documents/LE-SA-v1.8-July-06-2026.pdf. You must agree in | order to register with the ACME server. Do you agree? | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | (Y)es/(N)o: Y | | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | Would you be willing, once your first certificate is successfully issued, to | share your email address with the Electronic Frontier Foundation, a founding | partner of the Let's Encrypt project and the non-profit organization that | develops Certbot? We'd like to send you email about our work encrypting the web, | EFF news, campaigns, and ways to support digital freedom. | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | (Y)es/(N)o: N | Account registered. | Requesting a certificate for example.com and www.example.com | | Successfully received certificate. | Certificate is saved at: /etc/letsencrypt/live/example.com/fullchain.pem | Key is saved at: /etc/letsencrypt/live/example.com/privkey.pem | This certificate expires on 2027-02-10. | These files will be updated when the certificate renews. | Certbot has set up a scheduled task to automatically renew this certificate in the background. | | Deploying certificate | Successfully deployed certificate for example.com to /etc/nginx/sites-enabled/example.com | Successfully deployed certificate for www.example.com to /etc/nginx/sites-enabled/example.com | Congratulations! You have successfully enabled HTTPS on https://example.com and https://www.example.com | | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | If you like Certbot, please consider supporting our work by: | * Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate | * Donating to EFF: https://eff.org/donate-le | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 13. ok "Successfully received certificate" and the paths under /etc/letsencrypt/live/example.com/ | Saving debug log to /var/log/letsencrypt/letsencrypt.log | Enter email address (used for urgent renewal and security notices) | (Enter 'c' to cancel): admin@example.com | | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | Please read the Terms of Service at | https://letsencrypt.org/documents/LE-SA-v1.8-July-06-2026.pdf. You must agree in | order to register with the ACME server. Do you agree? | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | (Y)es/(N)o: Y | | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | Would you be willing, once your first certificate is successfully issued, to | share your email address with the Electronic Frontier Foundation, a founding | partner of the Let's Encrypt project and the non-profit organization that | develops Certbot? We'd like to send you email about our work encrypting the web, | EFF news, campaigns, and ways to support digital freedom. | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | (Y)es/(N)o: N | Account registered. | Requesting a certificate for example.com and www.example.com | | Successfully received certificate. | Certificate is saved at: /etc/letsencrypt/live/example.com/fullchain.pem | Key is saved at: /etc/letsencrypt/live/example.com/privkey.pem | This certificate expires on 2027-02-10. | These files will be updated when the certificate renews. | Certbot has set up a scheduled task to automatically renew this certificate in the background. | | Deploying certificate | Successfully deployed certificate for example.com to /etc/nginx/sites-enabled/example.com | Successfully deployed certificate for www.example.com to /etc/nginx/sites-enabled/example.com | Congratulations! You have successfully enabled HTTPS on https://example.com and https://www.example.com | | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | If you like Certbot, please consider supporting our work by: | * Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate | * Donating to EFF: https://eff.org/donate-le | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 14. ok certbot deploys it into the server block for both names and says "Congratulations!" | Saving debug log to /var/log/letsencrypt/letsencrypt.log | Enter email address (used for urgent renewal and security notices) | (Enter 'c' to cancel): admin@example.com | | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | Please read the Terms of Service at | https://letsencrypt.org/documents/LE-SA-v1.8-July-06-2026.pdf. You must agree in | order to register with the ACME server. Do you agree? | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | (Y)es/(N)o: Y | | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | Would you be willing, once your first certificate is successfully issued, to | share your email address with the Electronic Frontier Foundation, a founding | partner of the Let's Encrypt project and the non-profit organization that | develops Certbot? We'd like to send you email about our work encrypting the web, | EFF news, campaigns, and ways to support digital freedom. | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | (Y)es/(N)o: N | Account registered. | Requesting a certificate for example.com and www.example.com | | Successfully received certificate. | Certificate is saved at: /etc/letsencrypt/live/example.com/fullchain.pem | Key is saved at: /etc/letsencrypt/live/example.com/privkey.pem | This certificate expires on 2027-02-10. | These files will be updated when the certificate renews. | Certbot has set up a scheduled task to automatically renew this certificate in the background. | | Deploying certificate | Successfully deployed certificate for example.com to /etc/nginx/sites-enabled/example.com | Successfully deployed certificate for www.example.com to /etc/nginx/sites-enabled/example.com | Congratulations! You have successfully enabled HTTPS on https://example.com and https://www.example.com | | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | If you like Certbot, please consider supporting our work by: | * Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate | * Donating to EFF: https://eff.org/donate-le | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 15. ok certbot did NOT ask about a redirect (2.x adds it by default) | Saving debug log to /var/log/letsencrypt/letsencrypt.log | Enter email address (used for urgent renewal and security notices) | (Enter 'c' to cancel): admin@example.com | | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | Please read the Terms of Service at | https://letsencrypt.org/documents/LE-SA-v1.8-July-06-2026.pdf. You must agree in | order to register with the ACME server. Do you agree? | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | (Y)es/(N)o: Y | | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | Would you be willing, once your first certificate is successfully issued, to | share your email address with the Electronic Frontier Foundation, a founding | partner of the Let's Encrypt project and the non-profit organization that | develops Certbot? We'd like to send you email about our work encrypting the web, | EFF news, campaigns, and ways to support digital freedom. | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | (Y)es/(N)o: N | Account registered. | Requesting a certificate for example.com and www.example.com | | Successfully received certificate. | Certificate is saved at: /etc/letsencrypt/live/example.com/fullchain.pem | Key is saved at: /etc/letsencrypt/live/example.com/privkey.pem | This certificate expires on 2027-02-10. | These files will be updated when the certificate renews. | Certbot has set up a scheduled task to automatically renew this certificate in the background. | | Deploying certificate | Successfully deployed certificate for example.com to /etc/nginx/sites-enabled/example.com | Successfully deployed certificate for www.example.com to /etc/nginx/sites-enabled/example.com | Congratulations! You have successfully enabled HTTPS on https://example.com and https://www.example.com | | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | If you like Certbot, please consider supporting our work by: | * Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate | * Donating to EFF: https://eff.org/donate-le | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 16. ok (the certificate's lifetime is read from the run: 90 days) | 2027-02-10 17. ok curl -I https://example.com: "HTTP/1.1 200 OK" (curl trusts the certificate) | HTTP/1.1 200 OK | Server: nginx/1.24.0 (Ubuntu) | Date: Thu, 12 Nov 2026 06:14:14 GMT | Content-Type: text/html | Content-Length: 34 | Last-Modified: Thu, 12 Nov 2026 06:13:05 GMT | Connection: keep-alive | ETag: "6af558f1-22" | Accept-Ranges: bytes 18. ok http:// now answers "301 Moved Permanently" with "Location: https://example.com/" | HTTP/1.1 301 Moved Permanently | Server: nginx/1.24.0 (Ubuntu) | Date: Thu, 12 Nov 2026 06:14:18 GMT | Content-Type: text/html | Content-Length: 178 | Connection: keep-alive | Location: https://example.com/ 19. ok openssl shows subject CN = example.com and a Let’s Encrypt issuer | subject=CN = example.com | issuer=C = US, O = Let's Encrypt, CN = YE2 | notBefore=Nov 12 05:15:35 2026 GMT | notAfter=Feb 10 05:15:34 2027 GMT 20. ok (from another network) https://example.com and https://www.example.com answer 200 with a trusted certificate 21. ok (from another network) http:// answers 301 22. ok certbot certificates lists both names, key type ECDSA, and "VALID: N days" | Saving debug log to /var/log/letsencrypt/letsencrypt.log | | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | Found the following certs: | Certificate Name: example.com | Serial Number: | Key Type: ECDSA | Domains: example.com www.example.com | Expiry Date: 2027-02-10 05:15:34+00:00 (VALID: 89 days) | Certificate Path: /etc/letsencrypt/live/example.com/fullchain.pem | Private Key Path: /etc/letsencrypt/live/example.com/privkey.pem | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 23. ok the original block now listens on 443 ssl with the certificate lines "# managed by Certbot" | server { | server_name example.com www.example.com; | root /var/www/example.com; | index index.html; | | listen [::]:443 ssl ipv6only=on; # managed by Certbot | listen 443 ssl; # managed by Certbot | ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot | ssl_certificate_key /etc/letsencrypt/live/example.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 | | | } | server { | if ($host = www.example.com) { | return 301 https://$host$request_uri; | } # managed by Certbot | | | if ($host = example.com) { | return 301 https://$host$request_uri; | } # managed by Certbot | | | listen 80; | listen [::]:80; | server_name example.com www.example.com; | return 404; # managed by Certbot | | | | | } 24. ok a NEW port-80 block redirects each name with if ($host = …) return 301, and returns 404 for anything else | server { | server_name example.com www.example.com; | root /var/www/example.com; | index index.html; | | listen [::]:443 ssl ipv6only=on; # managed by Certbot | listen 443 ssl; # managed by Certbot | ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot | ssl_certificate_key /etc/letsencrypt/live/example.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 | | | } | server { | if ($host = www.example.com) { | return 301 https://$host$request_uri; | } # managed by Certbot | | | if ($host = example.com) { | return 301 https://$host$request_uri; | } # managed by Certbot | | | listen 80; | listen [::]:80; | server_name example.com www.example.com; | return 404; # managed by Certbot | | | | | } 25. ok the [::]:443 listen line has ipv6only=on | server { | server_name example.com www.example.com; | root /var/www/example.com; | index index.html; | | listen [::]:443 ssl ipv6only=on; # managed by Certbot | listen 443 ssl; # managed by Certbot | ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot | ssl_certificate_key /etc/letsencrypt/live/example.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 | | | } | server { | if ($host = www.example.com) { | return 301 https://$host$request_uri; | } # managed by Certbot | | | if ($host = example.com) { | return 301 https://$host$request_uri; | } # managed by Certbot | | | listen 80; | listen [::]:80; | server_name example.com www.example.com; | return 404; # managed by Certbot | | | | | } 26. ok (the file in sites-enabled is still the symlink, so the change is in sites-available) | lrwxrwxrwx 1 root root 45 Nov 12 06:13 /etc/nginx/sites-enabled/example.com -> /etc/nginx/sites-available/example.com 27. ok certbot.timer is listed with its next run | NEXT LEFT LAST PASSED UNIT ACTIVATES | Thu 2026-11-12 12:56:07 UTC 6h - - certbot.timer certbot.service | | 1 timers listed. | Pass --all to see loaded but inactive timers, too. 28. ok the renewal file says "# renew_before_expiry = 30 days" | # renew_before_expiry = 30 days 29. ok certbot renew --dry-run: "Congratulations, all simulated renewals succeeded" | Saving debug log to /var/log/letsencrypt/letsencrypt.log | | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | Processing /etc/letsencrypt/renewal/example.com.conf | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | Account registered. | Simulating renewal of an existing certificate for example.com and www.example.com | | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | Congratulations, all simulated renewals succeeded: | /etc/letsencrypt/live/example.com/fullchain.pem (success) | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 30. ok (from another network) with only 443 open, https still works and http gets no answer 31. ok the dry run fails: "Timeout during connect (likely firewall problem)" | Saving debug log to /var/log/letsencrypt/letsencrypt.log | | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | Processing /etc/letsencrypt/renewal/example.com.conf | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | Simulating renewal of an existing certificate for example.com and www.example.com | | Certbot failed to authenticate some domains (authenticator: nginx). The Certificate Authority reported these problems: | Domain: example.com | Type: connection | Detail: 203.0.113.10: Fetching http://example.com/.well-known/acme-challenge/UOUE0RmD1oKPXUNFzUrPvQIi_4EvhDutdMuBF0zKLdM: Timeout during connect (likely firewall problem) | | Domain: www.example.com | Type: connection | Detail: 203.0.113.10: Fetching http://www.example.com/.well-known/acme-challenge/oqiDeZag5TAl9LjsdF8kdz7ymRyUIrflmC7Dm5U1Gs0: Timeout during connect (likely firewall problem) | | Hint: The Certificate Authority failed to verify the temporary nginx configuration changes made by Certbot. Ensure the listed domains point to this nginx server and that it is accessible from the internet. | | Failed to renew certificate example.com with error: Some challenges have failed. | | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | All simulated renewals failed. The following certificates could not be renewed: | /etc/letsencrypt/live/example.com/fullchain.pem (failure) | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 1 renew failure(s), 0 parse failure(s) | Ask for help or search for solutions at https://community.letsencrypt.org. See the logfile /var/log/letsencrypt/letsencrypt.log or re-run Certbot with -v for more details. 32. ok with port 80 open again, the dry run succeeds | Saving debug log to /var/log/letsencrypt/letsencrypt.log | | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | Processing /etc/letsencrypt/renewal/example.com.conf | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | Simulating renewal of an existing certificate for example.com and www.example.com | | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | Congratulations, all simulated renewals succeeded: | /etc/letsencrypt/live/example.com/fullchain.pem (success) | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 33. ok (tested on) the box reports its OS, kernel and the version of 5 package(s) | PRETTY_NAME="Ubuntu 24.04.4 LTS" | VIRT=none | KERNEL=6.8.0-117-generic | PKG certbot 2.9.0-1 | PKG nginx 1.24.0-2ubuntu7.19 | PKG python3-acme 2.9.0-1 | PKG python3-certbot-nginx 2.9.0-1 | PKG ufw 0.36.2-6 34. ok revoke asks whether to delete the files too (Y), warns that a certificate still in use stops the server software, asks again (Y) | Saving debug log to /var/log/letsencrypt/letsencrypt.log | | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | Would you like to delete the certificate(s) you just revoked, along with all | earlier and later versions of the certificate? | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | (Y)es (recommended)/(N)o: Y | | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | The following certificate(s) are selected for deletion: | | * example.com | | WARNING: Before continuing, ensure that the listed certificates are not being | used by any installed server software (e.g. Apache, nginx, mail servers). | Deleting a certificate that is still being used will cause the server software | to stop working. See https://certbot.org/deleting-certs for information on | deleting certificates safely. | | Are you sure you want to delete the above certificate(s)? | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | (Y)es/(N)o: Y | Deleted all files relating to certificate example.com. | Congratulations! You have successfully revoked the certificate that was located at /etc/letsencrypt/live/example.com/cert.pem. 35. ok …and both happen: "Deleted all files relating to certificate example.com" and the revoke is confirmed | Saving debug log to /var/log/letsencrypt/letsencrypt.log | | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | Would you like to delete the certificate(s) you just revoked, along with all | earlier and later versions of the certificate? | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | (Y)es (recommended)/(N)o: Y | | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | The following certificate(s) are selected for deletion: | | * example.com | | WARNING: Before continuing, ensure that the listed certificates are not being | used by any installed server software (e.g. Apache, nginx, mail servers). | Deleting a certificate that is still being used will cause the server software | to stop working. See https://certbot.org/deleting-certs for information on | deleting certificates safely. | | Are you sure you want to delete the above certificate(s)? | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | (Y)es/(N)o: Y | Deleted all files relating to certificate example.com. | Congratulations! You have successfully revoked the certificate that was located at /etc/letsencrypt/live/example.com/cert.pem. 36. ok nginx -t now FAILS: the server block still names the deleted certificate files | 2026/11/12 06:16:30 [emerg] 5088#5088: cannot load certificate "/etc/letsencrypt/live/example.com/fullchain.pem": BIO_new_file() failed (SSL: error:80000002:system library::No such file or directory:calling fopen(/etc/letsencrypt/live/example.com/fullchain.pem, r) error:10000080:BIO routines::no such file) | nginx: configuration file /etc/nginx/nginx.conf test failed 37. ok (the running Nginx keeps serving until a reload or restart) 38. ok with the plain port-80 block back, nginx -t is successful | nginx: the configuration file /etc/nginx/nginx.conf syntax is ok | nginx: configuration file /etc/nginx/nginx.conf test is successful 39. ok (from another network) the site answers 200 on http again ------------------------------------------------------------------------------ Commands and what they printed (30) ------------------------------------------------------------------------------ $ dig +short example.com www.example.com 203.0.113.10 203.0.113.10 $ sudo mkdir -p /var/www/example.com $ echo '

example.com works

' | sudo tee /var/www/example.com/index.html

example.com works

$ sudo tee /etc/nginx/sites-available/example.com > /dev/null <<'EOF' $ server { $ listen 80; $ listen [::]:80; $ server_name example.com www.example.com; $ root /var/www/example.com; $ index index.html; $ } $ EOF $ sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/ $ sudo nginx -t nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful $ sudo systemctl reload nginx $ curl http://example.com

example.com works

$ sudo apt install -y certbot python3-certbot-nginx Reading package lists... Done Building dependency tree... Done Reading state information... Done The following additional packages will be installed: python3-acme python3-certbot python3-configargparse python3-icu python3-josepy python3-parsedatetime python3-rfc3339 Suggested packages: python-certbot-doc python3-certbot-apache python-acme-doc python-certbot-nginx-doc The following NEW packages will be installed: certbot python3-acme python3-certbot python3-certbot-nginx python3-configargparse python3-icu python3-josepy python3-parsedatetime python3-rfc3339 0 upgraded, 9 newly installed, 0 to remove and 183 not upgraded. Need to get 1,097 kB of archives. After this operation, 5,699 kB of additional disk space will be used. Get:1 https://mirror.hetzner.com/ubuntu/packages noble/universe amd64 python3-josepy all 1.14.0-1 [22.1 kB] Get:2 https://mirror.hetzner.com/ubuntu/packages noble/universe amd64 python3-rfc3339 all 1.1-4 [6,744 B] Get:3 https://mirror.hetzner.com/ubuntu/packages noble/universe amd64 python3-acme all 2.9.0-1 [48.5 kB] Get:4 https://mirror.hetzner.com/ubuntu/packages noble/universe amd64 python3-configargparse all 1.7-1 [31.7 kB] Get:5 https://mirror.hetzner.com/ubuntu/packages noble/universe amd64 python3-parsedatetime all 2.6-3 [32.8 kB] Get:6 https://mirror.hetzner.com/ubuntu/packages noble/universe amd64 python3-certbot all 2.9.0-1 [267 kB] Get:7 https://mirror.hetzner.com/ubuntu/packages noble/universe amd64 certbot all 2.9.0-1 [89.2 kB] Get:8 https://mirror.hetzner.com/ubuntu/packages noble/universe amd64 python3-certbot-nginx all 2.9.0-1 [66.0 kB] Get:9 https://mirror.hetzner.com/ubuntu/packages noble/main amd64 python3-icu amd64 2.12-1build2 [534 kB] Fetched 1,097 kB in 0s (2,473 kB/s) Preconfiguring packages ... Selecting previously unselected package python3-josepy. (Reading database ... 38794 files and directories currently installed.) Preparing to unpack .../0-python3-josepy_1.14.0-1_all.deb ... Unpacking python3-josepy (1.14.0-1) ... Selecting previously unselected package python3-rfc3339. Preparing to unpack .../1-python3-rfc3339_1.1-4_all.deb ... Unpacking python3-rfc3339 (1.1-4) ... Selecting previously unselected package python3-acme. Preparing to unpack .../2-python3-acme_2.9.0-1_all.deb ... Unpacking python3-acme (2.9.0-1) ... Selecting previously unselected package python3-configargparse. Preparing to unpack .../3-python3-configargparse_1.7-1_all.deb ... Unpacking python3-configargparse (1.7-1) ... Selecting previously unselected package python3-parsedatetime. Preparing to unpack .../4-python3-parsedatetime_2.6-3_all.deb ... Unpacking python3-parsedatetime (2.6-3) ... Selecting previously unselected package python3-certbot. Preparing to unpack .../5-python3-certbot_2.9.0-1_all.deb ... Unpacking python3-certbot (2.9.0-1) ... Selecting previously unselected package certbot. Preparing to unpack .../6-certbot_2.9.0-1_all.deb ... Unpacking certbot (2.9.0-1) ... Selecting previously unselected package python3-certbot-nginx. Preparing to unpack .../7-python3-certbot-nginx_2.9.0-1_all.deb ... Unpacking python3-certbot-nginx (2.9.0-1) ... Selecting previously unselected package python3-icu. Preparing to unpack .../8-python3-icu_2.12-1build2_amd64.deb ... Unpacking python3-icu (2.12-1build2) ... Setting up python3-configargparse (1.7-1) ... Setting up python3-parsedatetime (2.6-3) ... Setting up python3-icu (2.12-1build2) ... Setting up python3-josepy (1.14.0-1) ... Setting up python3-rfc3339 (1.1-4) ... Setting up python3-acme (2.9.0-1) ... Setting up python3-certbot (2.9.0-1) ... Setting up certbot (2.9.0-1) ... Created symlink /etc/systemd/system/timers.target.wants/certbot.timer → /usr/lib/systemd/system/certbot.timer. Setting up python3-certbot-nginx (2.9.0-1) ... Processing triggers for man-db (2.12.0-4build2) ... Scanning processes... Scanning linux images... Running kernel seems to be up-to-date. No services need to be restarted. No containers need to be restarted. No user sessions are running outdated binaries. No VM guests are running outdated hypervisor (qemu) binaries on this host. $ certbot --version certbot 2.9.0 $ sudo certbot --nginx -d example.com -d www.example.com Saving debug log to /var/log/letsencrypt/letsencrypt.log Enter email address (used for urgent renewal and security notices) (Enter 'c' to cancel): admin@example.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Please read the Terms of Service at https://letsencrypt.org/documents/LE-SA-v1.8-July-06-2026.pdf. You must agree in order to register with the ACME server. Do you agree? - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (Y)es/(N)o: Y - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Would you be willing, once your first certificate is successfully issued, to share your email address with the Electronic Frontier Foundation, a founding partner of the Let's Encrypt project and the non-profit organization that develops Certbot? We'd like to send you email about our work encrypting the web, EFF news, campaigns, and ways to support digital freedom. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (Y)es/(N)o: N Account registered. Requesting a certificate for example.com and www.example.com Successfully received certificate. Certificate is saved at: /etc/letsencrypt/live/example.com/fullchain.pem Key is saved at: /etc/letsencrypt/live/example.com/privkey.pem This certificate expires on 2027-02-10. These files will be updated when the certificate renews. Certbot has set up a scheduled task to automatically renew this certificate in the background. Deploying certificate Successfully deployed certificate for example.com to /etc/nginx/sites-enabled/example.com Successfully deployed certificate for www.example.com to /etc/nginx/sites-enabled/example.com Congratulations! You have successfully enabled HTTPS on https://example.com and https://www.example.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - If you like Certbot, please consider supporting our work by: * Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate * Donating to EFF: https://eff.org/donate-le - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $ curl -I https://example.com HTTP/1.1 200 OK Server: nginx/1.24.0 (Ubuntu) Date: Thu, 12 Nov 2026 06:14:14 GMT Content-Type: text/html Content-Length: 34 Last-Modified: Thu, 12 Nov 2026 06:13:05 GMT Connection: keep-alive ETag: "6af558f1-22" Accept-Ranges: bytes $ curl -I http://example.com HTTP/1.1 301 Moved Permanently Server: nginx/1.24.0 (Ubuntu) Date: Thu, 12 Nov 2026 06:14:18 GMT Content-Type: text/html Content-Length: 178 Connection: keep-alive Location: https://example.com/ $ echo | openssl s_client -connect example.com:443 -servername example.com 2>/dev/null | openssl x509 -noout -subject -issuer -dates subject=CN = example.com issuer=C = US, O = Let's Encrypt, CN = YE2 notBefore=Nov 12 05:15:35 2026 GMT notAfter=Feb 10 05:15:34 2027 GMT $ sudo certbot certificates Saving debug log to /var/log/letsencrypt/letsencrypt.log - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Found the following certs: Certificate Name: example.com Serial Number: Key Type: ECDSA Domains: example.com www.example.com Expiry Date: 2027-02-10 05:15:34+00:00 (VALID: 89 days) Certificate Path: /etc/letsencrypt/live/example.com/fullchain.pem Private Key Path: /etc/letsencrypt/live/example.com/privkey.pem - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $ cat /etc/nginx/sites-available/example.com server { server_name example.com www.example.com; root /var/www/example.com; index index.html; listen [::]:443 ssl ipv6only=on; # managed by Certbot listen 443 ssl; # managed by Certbot ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot ssl_certificate_key /etc/letsencrypt/live/example.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 } server { if ($host = www.example.com) { return 301 https://$host$request_uri; } # managed by Certbot if ($host = example.com) { return 301 https://$host$request_uri; } # managed by Certbot listen 80; listen [::]:80; server_name example.com www.example.com; return 404; # managed by Certbot } $ systemctl list-timers certbot.timer --no-pager NEXT LEFT LAST PASSED UNIT ACTIVATES Thu 2026-11-12 12:56:07 UTC 6h - - certbot.timer certbot.service 1 timers listed. Pass --all to see loaded but inactive timers, too. $ sudo grep renew_before_expiry /etc/letsencrypt/renewal/example.com.conf # renew_before_expiry = 30 days $ sudo certbot renew --dry-run Saving debug log to /var/log/letsencrypt/letsencrypt.log - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Processing /etc/letsencrypt/renewal/example.com.conf - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Account registered. Simulating renewal of an existing certificate for example.com and www.example.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Congratulations, all simulated renewals succeeded: /etc/letsencrypt/live/example.com/fullchain.pem (success) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $ sudo ufw delete allow 'Nginx Full' Rule deleted Rule deleted (v6) $ sudo ufw allow 'Nginx HTTPS' Rule added Rule added (v6) $ sudo certbot renew --dry-run Saving debug log to /var/log/letsencrypt/letsencrypt.log - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Processing /etc/letsencrypt/renewal/example.com.conf - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Simulating renewal of an existing certificate for example.com and www.example.com Certbot failed to authenticate some domains (authenticator: nginx). The Certificate Authority reported these problems: Domain: example.com Type: connection Detail: 203.0.113.10: Fetching http://example.com/.well-known/acme-challenge/UOUE0RmD1oKPXUNFzUrPvQIi_4EvhDutdMuBF0zKLdM: Timeout during connect (likely firewall problem) Domain: www.example.com Type: connection Detail: 203.0.113.10: Fetching http://www.example.com/.well-known/acme-challenge/oqiDeZag5TAl9LjsdF8kdz7ymRyUIrflmC7Dm5U1Gs0: Timeout during connect (likely firewall problem) Hint: The Certificate Authority failed to verify the temporary nginx configuration changes made by Certbot. Ensure the listed domains point to this nginx server and that it is accessible from the internet. Failed to renew certificate example.com with error: Some challenges have failed. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - All simulated renewals failed. The following certificates could not be renewed: /etc/letsencrypt/live/example.com/fullchain.pem (failure) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1 renew failure(s), 0 parse failure(s) Ask for help or search for solutions at https://community.letsencrypt.org. See the logfile /var/log/letsencrypt/letsencrypt.log or re-run Certbot with -v for more details. $ sudo ufw allow 'Nginx Full' Rule added Rule added (v6) $ sudo ufw delete allow 'Nginx HTTPS' Rule deleted Rule deleted (v6) $ sudo certbot renew --dry-run Saving debug log to /var/log/letsencrypt/letsencrypt.log - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Processing /etc/letsencrypt/renewal/example.com.conf - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Simulating renewal of an existing certificate for example.com and www.example.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Congratulations, all simulated renewals succeeded: /etc/letsencrypt/live/example.com/fullchain.pem (success) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $ sudo certbot revoke --cert-name example.com Saving debug log to /var/log/letsencrypt/letsencrypt.log - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Would you like to delete the certificate(s) you just revoked, along with all earlier and later versions of the certificate? - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (Y)es (recommended)/(N)o: Y - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - The following certificate(s) are selected for deletion: * example.com WARNING: Before continuing, ensure that the listed certificates are not being used by any installed server software (e.g. Apache, nginx, mail servers). Deleting a certificate that is still being used will cause the server software to stop working. See https://certbot.org/deleting-certs for information on deleting certificates safely. Are you sure you want to delete the above certificate(s)? - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (Y)es/(N)o: Y Deleted all files relating to certificate example.com. Congratulations! You have successfully revoked the certificate that was located at /etc/letsencrypt/live/example.com/cert.pem. $ sudo nginx -t 2026/11/12 06:16:30 [emerg] 5088#5088: cannot load certificate "/etc/letsencrypt/live/example.com/fullchain.pem": BIO_new_file() failed (SSL: error:80000002:system library::No such file or directory:calling fopen(/etc/letsencrypt/live/example.com/fullchain.pem, r) error:10000080:BIO routines::no such file) nginx: configuration file /etc/nginx/nginx.conf test failed $ sudo tee /etc/nginx/sites-available/example.com > /dev/null <<'EOF' $ server { $ listen 80; $ listen [::]:80; $ server_name example.com www.example.com; $ root /var/www/example.com; $ index index.html; $ } $ EOF $ sudo nginx -t nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful $ sudo systemctl reload nginx ------------------------------------------------------------------------------ The check's source (scripts/live/checks/lets-encrypt-nginx-ubuntu-24-04.mjs) As it ran. ------------------------------------------------------------------------------ /** * KB: Let's Encrypt for Nginx on Ubuntu 24.04 with certbot: check DNS, a server block for the domain, install certbot, * get the certificate (the real prompts), check HTTPS and the redirect from the server and from another network, what * certbot changed in the server block, renewal (timer + dry run), the renewal that fails when port 80 is closed, and * removing the certificate (revoke + delete, then the config that no longer loads, and the fix). * * Runs ONLY on a real rented server (LIVE_VPS=root@
LIVE_VPS_DOMAIN=, box.mjs `vps`): Let's Encrypt * must reach the server's port 80 from the internet, which no local box can offer. The server is the provider's stock * Ubuntu 24.04 image with a public IPv4 and IPv6; the domain and its www name have A records pointing at it (no AAAA). * Commands use example.com; box.mjs swaps the real name in on the way out and back on the way in. * * Hidden setup, as the earlier articles leave the server: the sudo user `deploy`, ufw on with SSH allowed, Nginx * installed and 'Nginx Full' allowed. "From another network" is the machine running this check (the laptop), which * reaches the server over the internet exactly as a visitor does. * * LIVE_LE_STAGING=1 sends every certbot request to Let's Encrypt's STAGING server (adds --test-cert to the command * sent, never to the command shown) so a check being written does not use up the real rate limits. Such a run is * never saved (meta.saveRun false): its certificate is not trusted, so the HTTPS claims fail on purpose. */ import { spawnSync } from 'node:child_process' import { VPS, VPS_DOMAIN } from '../box.mjs' import { bareBox, reportBox } from '../lib.mjs' const STAGING = process.env.LIVE_LE_STAGING === '1' export const meta = { saveRun: !STAGING } /** The page's command → what is sent: with LIVE_LE_STAGING, certbot asks the staging server. */ const le = (cmd) => (STAGING ? cmd.replace(/^sudo certbot (\S+)/, 'sudo certbot $1 --test-cert') : cmd) /** From another network (this machine), over the internet: the HTTP status, '000' = no answer. */ const fromOutside = (url) => spawnSync('curl', ['-s', '-o', '/dev/null', '-m', '10', '-w', '%{http_code}', url.replace('example.com', VPS_DOMAIN)], { encoding: 'utf8', }).stdout const SERVER_BLOCK = `server { listen 80; listen [::]:80; server_name example.com www.example.com; root /var/www/example.com; index index.html; }` const check = (ctx) => { if (!VPS) { ctx.check('this check runs on a real rented server (LIVE_VPS and LIVE_VPS_DOMAIN set)', false, 'LIVE_VPS is not set') return } return bareBox(ctx, async ({ sudoUser }) => { const { run, ask, L } = sudoUser() L('sudo true') // ── hidden: as the UFW and Nginx articles leave the server ────────────────────────────── L('sudo ufw allow OpenSSH && sudo ufw --force enable') L('sudo apt-get update -qq && sudo DEBIAN_FRONTEND=noninteractive apt-get install -y -qq nginx', 900000) L("sudo ufw allow 'Nginx Full'") ctx.check( '(setup) ufw on with OpenSSH and Nginx Full allowed, Nginx running, as after the earlier articles', /Nginx Full\s+ALLOW/.test(L('sudo ufw status')) && L('systemctl is-active nginx') === 'active', L('sudo ufw status'), ) // ── step 1: the domain points at the server ───────────────────────────────────────────── const dig = run('dig +short example.com www.example.com', { id: 'dig' }) ctx.check('dig prints the server’s address for both names', dig.out === '203.0.113.10\n203.0.113.10', dig.out) // ── step 2: a server block for the domain ─────────────────────────────────────────────── run('sudo mkdir -p /var/www/example.com', { id: 'mkdir' }) const page = run("echo '

example.com works

' | sudo tee /var/www/example.com/index.html", { id: 'page' }) ctx.check('tee prints the page it wrote', page.out === '

example.com works

', page.out) const tee = run(`sudo tee /etc/nginx/sites-available/example.com > /dev/null <<'EOF'\n${SERVER_BLOCK}\nEOF`, { id: 'block' }) ctx.check('the server block is written (tee prints nothing with > /dev/null)', tee.exit === 0 && tee.out === '', tee.out) run('sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/', { id: 'enable' }) const t1 = run('sudo nginx -t', { id: 'test-block' }) ctx.check('nginx -t is successful with the new server block', t1.exit === 0 && /test is successful/.test(t1.out), t1.out) run('sudo systemctl reload nginx', { id: 'reload-block' }) const http1 = run('curl http://example.com', { id: 'curl-http' }) ctx.check('the domain serves the new page over HTTP', http1.out === '

example.com works

', http1.out) ctx.check('(from another network) http://example.com and www answer 200', fromOutside('http://example.com/') === '200' && fromOutside('http://www.example.com/') === '200', '') // ── step 3: install certbot ───────────────────────────────────────────────────────────── const inst = run('sudo apt install -y certbot python3-certbot-nginx', { id: 'apt-install', timeout: 900000 }) ctx.check('apt installs certbot 2.9.0 and its Nginx plugin from Ubuntu’s repository', inst.exit === 0 && /Setting up certbot \(2\.9\.0/.test(inst.out) && /Setting up python3-certbot-nginx \(2\.9\.0/.test(inst.out), inst.out.slice(-1500)) const ver = run('certbot --version', { id: 'version' }) ctx.check('certbot --version: "certbot 2.9.0"', ver.out === 'certbot 2.9.0', ver.out) const timer0 = L('systemctl is-enabled certbot.timer; systemctl is-active certbot.timer') ctx.check('(the package already turned on certbot.timer, before any certificate exists)', timer0 === 'enabled\nactive', timer0) // ── step 4: get the certificate ───────────────────────────────────────────────────────── const show = 'sudo certbot --nginx -d example.com -d www.example.com' const cb = ask( le(show), [ ['Enter email address', 'admin@example.com'], ['\\(Y\\)es/\\(N\\)o', 'Y'], ['\\(Y\\)es/\\(N\\)o', 'N'], ], { show, id: 'certbot', timeout: 300, publicReplies: true }, ) ctx.check('certbot asks for an email, the Terms of Service (Y) and the EFF mailing list (N)', /Enter email address/.test(cb.out) && /Terms of Service/.test(cb.out) && /Electronic Frontier Foundation/.test(cb.out), cb.out) ctx.check('"Successfully received certificate" and the paths under /etc/letsencrypt/live/example.com/', cb.exit === 0 && /Successfully received certificate/.test(cb.out) && /\/etc\/letsencrypt\/live\/example\.com\/fullchain\.pem/.test(cb.out), cb.out) ctx.check('certbot deploys it into the server block for both names and says "Congratulations!"', /Successfully deployed certificate for example\.com to \/etc\/nginx\/sites-enabled\/example\.com/.test(cb.out) && /Successfully deployed certificate for www\.example\.com/.test(cb.out) && /Congratulations!/.test(cb.out), cb.out) ctx.check('certbot did NOT ask about a redirect (2.x adds it by default)', !/redirect/i.test(cb.out.split('Deploying certificate')[0] ?? ''), cb.out) const exp = (cb.out.match(/This certificate expires on (\d{4}-\d{2}-\d{2})/) ?? [])[1] const days = exp ? Math.round((Date.parse(exp) - Date.now()) / 86400000) : NaN ctx.check(`(the certificate's lifetime is read from the run: ${days} days)`, Number.isFinite(days) && days > 30 && days <= 100, String(exp)) // ── step 5: check it works ────────────────────────────────────────────────────────────── const https = run('curl -I https://example.com', { id: 'curl-https' }) ctx.check('curl -I https://example.com: "HTTP/1.1 200 OK" (curl trusts the certificate)', /^HTTP\/1\.1 200 OK/.test(https.out), https.out) const redir = run('curl -I http://example.com', { id: 'curl-redirect' }) ctx.check('http:// now answers "301 Moved Permanently" with "Location: https://example.com/"', /^HTTP\/1\.1 301 Moved Permanently/.test(redir.out) && /Location: https:\/\/example\.com\//.test(redir.out), redir.out) const ssl = run('echo | openssl s_client -connect example.com:443 -servername example.com 2>/dev/null | openssl x509 -noout -subject -issuer -dates', { id: 'openssl' }) ctx.check('openssl shows subject CN = example.com and a Let’s Encrypt issuer', /subject=CN = example\.com/.test(ssl.out) && /issuer=C = US, O = Let's Encrypt/.test(ssl.out), ssl.out) ctx.check('(from another network) https://example.com and https://www.example.com answer 200 with a trusted certificate', fromOutside('https://example.com/') === '200' && fromOutside('https://www.example.com/') === '200', '') ctx.check('(from another network) http:// answers 301', fromOutside('http://example.com/') === '301', '') const certs = run('sudo certbot certificates', { id: 'certificates' }) ctx.check('certbot certificates lists both names, key type ECDSA, and "VALID: N days"', /Domains: example\.com www\.example\.com/.test(certs.out) && /Key Type: ECDSA/.test(certs.out) && /VALID: \d+ days/.test(certs.out), certs.out) // ── what certbot changed ──────────────────────────────────────────────────────────────── const cfg = run('cat /etc/nginx/sites-available/example.com', { id: 'cat-block' }) ctx.check('the original block now listens on 443 ssl with the certificate lines "# managed by Certbot"', /listen 443 ssl; # managed by Certbot/.test(cfg.out) && /ssl_certificate \/etc\/letsencrypt\/live\/example\.com\/fullchain\.pem; # managed by Certbot/.test(cfg.out), cfg.out) ctx.check('a NEW port-80 block redirects each name with if ($host = …) return 301, and returns 404 for anything else', /if \(\$host = www\.example\.com\) \{\s*return 301 https:\/\/\$host\$request_uri;/.test(cfg.out) && /return 404; # managed by Certbot/.test(cfg.out), cfg.out) ctx.check('the [::]:443 listen line has ipv6only=on', /listen \[::\]:443 ssl ipv6only=on; # managed by Certbot/.test(cfg.out), cfg.out) ctx.check('(the file in sites-enabled is still the symlink, so the change is in sites-available)', /->/.test(L('ls -l /etc/nginx/sites-enabled/example.com')), L('ls -l /etc/nginx/sites-enabled/example.com')) // ── renewal ───────────────────────────────────────────────────────────────────────────── const timer = run('systemctl list-timers certbot.timer --no-pager', { id: 'timer' }) ctx.check('certbot.timer is listed with its next run', /certbot\.timer\s+certbot\.service/.test(timer.out), timer.out) const conf = run('sudo grep renew_before_expiry /etc/letsencrypt/renewal/example.com.conf', { id: 'renew-before' }) ctx.check('the renewal file says "# renew_before_expiry = 30 days"', /# renew_before_expiry = 30 days/.test(conf.out), conf.out) const dry = run('sudo certbot renew --dry-run', { id: 'dry-run', timeout: 300000 }) ctx.check('certbot renew --dry-run: "Congratulations, all simulated renewals succeeded"', dry.exit === 0 && /Congratulations, all simulated renewals succeeded/.test(dry.out), dry.out) // ── port 80 closed: renewal fails ─────────────────────────────────────────────────────── run("sudo ufw delete allow 'Nginx Full'", { id: 'close-80-a' }) run("sudo ufw allow 'Nginx HTTPS'", { id: 'close-80-b' }) ctx.check('(from another network) with only 443 open, https still works and http gets no answer', fromOutside('https://example.com/') === '200' && fromOutside('http://example.com/') === '000', '') const fail = run('sudo certbot renew --dry-run', { id: 'dry-run-fail', timeout: 300000 }) ctx.check('the dry run fails: "Timeout during connect (likely firewall problem)"', fail.exit !== 0 && /Timeout during connect \(likely firewall problem\)/.test(fail.out), fail.out) run("sudo ufw allow 'Nginx Full'", { id: 'open-80-a' }) run("sudo ufw delete allow 'Nginx HTTPS'", { id: 'open-80-b' }) const dry2 = run('sudo certbot renew --dry-run', { id: 'dry-run-ok', timeout: 300000 }) ctx.check('with port 80 open again, the dry run succeeds', dry2.exit === 0 && /all simulated renewals succeeded/.test(dry2.out), dry2.out) reportBox( ctx, L, 'A fresh Ubuntu 24.04 cloud server from a hosting provider (its stock image, a public IPv4 address), with a domain and its www name pointed at it, ufw on and Nginx installed as the earlier articles leave it; reached over SSH as a sudo user. The certificate is a real one from Let’s Encrypt, and HTTPS was checked from another network.', ['nginx', 'certbot', 'python3-certbot-nginx', 'python3-acme', 'ufw'], ) // ── remove the certificate ────────────────────────────────────────────────────────────── const rev = ask( le('sudo certbot revoke --cert-name example.com'), [ ['\\(Y\\)es \\(recommended\\)/\\(N\\)o', 'Y'], ['Are you sure you want to delete[\\s\\S]*\\(Y\\)es/\\(N\\)o', 'Y'], ], { show: 'sudo certbot revoke --cert-name example.com', id: 'revoke', timeout: 300, publicReplies: true }, ) ctx.check('revoke asks whether to delete the files too (Y), warns that a certificate still in use stops the server software, asks again (Y)', /delete the certificate/.test(rev.out) && /Deleting a certificate that is still being used will cause the server software\s+to stop working/.test(rev.out) && /Are you sure you want to delete/.test(rev.out), rev.out) ctx.check('…and both happen: "Deleted all files relating to certificate example.com" and the revoke is confirmed', /Deleted all files relating to certificate example\.com/.test(rev.out) && /revoked/i.test(rev.out.split('Are you sure')[1] ?? ''), rev.out) const t2 = run('sudo nginx -t', { id: 'test-after-delete' }) ctx.check('nginx -t now FAILS: the server block still names the deleted certificate files', t2.exit !== 0 && /\/etc\/letsencrypt\/live\/example\.com\/fullchain\.pem/.test(t2.out) && /test failed/.test(t2.out), t2.out) ctx.check('(the running Nginx keeps serving until a reload or restart)', fromOutside('https://example.com/') === '200', '') run(`sudo tee /etc/nginx/sites-available/example.com > /dev/null <<'EOF'\n${SERVER_BLOCK}\nEOF`, { id: 'block-again' }) const t3 = run('sudo nginx -t', { id: 'test-restored' }) ctx.check('with the plain port-80 block back, nginx -t is successful', t3.exit === 0 && /test is successful/.test(t3.out), t3.out) run('sudo systemctl reload nginx', { id: 'reload-restored' }) ctx.check('(from another network) the site answers 200 on http again', fromOutside('http://example.com/') === '200', '') }) } export default check