Question

Website inaccessible after installing Let's encrypt certificate

Hello, I set up a droplet and configured nginx to serve a small static website. Everything was working fine until I installed a certificate using the Certbot script.

This is the nginx configuration file for the website:

server {

    root /var/www/angelacapillo.com;
    index index.php index.html index.htm;

    server_name angelacapillo.com www.angelacapillo.com;

    location / {
        try_files $uri $uri/ =404;
    }

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/angelacapillo.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/angelacapillo.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.angelacapillo.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot

    if ($host = angelacapillo.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot

    server_name angelacapillo.com www.angelacapillo.com;
    listen 80;
    return 404; # managed by Certbot
}

Following their instructions, I tested the certificate here but I get an error: https://www.ssllabs.com/ssltest/analyze.html?d=www.angelacapillo.com

What might be the issue?


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Accepted Answer

Hello @qarlo,

The syntax of your configuration file looks fine. What I could suggest here is:

  • First check if nginx is running:
systemctl status nginx
  • If Nginx is not running you could try starting it:
systemctl start nginx
  • If this is not the case, check if Nginx is actually listening on port 443:
netstat -plant | grep 443
  • If you don’t see any output, run a config test:
nginx -t
  • And if you get Syntax OK restart Nginx:
systemctl restart nginx
  • Lastly if all that does not help, make sure to check your Nginx error logs:
tail -100 /var/log/nginx/error.log

Hope that this helps! Regards, Bobby

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

For the benefit of future readers, I had the same issue after installing the Lets encrypt certificate using certbot.

Attempts to reload/restart nginx failed with errors already documented in this thread. systemctl status nginx showed that the nginx service had failed starting.

Because DO Firewall was in place, ufw was inactive.

Checking the ports showed that nginx processes were (still/already) listening to the port 443.

Rebooting the ubuntu server resolved the issue.