404 with certbot on Nginx

I have been using certbot for years on Apache2 web server, today was my first installation on an Nginx web server and I am facing some problems; whenever I install the certbot certificate on the below mentioned domain, it gives 404 on the browser, after some investigations I found that by commenting these commands in the domain virtual host file the domain works fine but of course without the certificate so don’t really know what is happening, please advise on how to investigate this issue

This is the section that causes the problem in the virtual host file which is the certificate:

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

listen 80;
server_name areej.website;
return 404; # managed by Certbot

}

"

  • My domain is: areej.website
  • I ran this command: sudo certbot
  • It produced this output: It produced the certificate needed for the domain after a few wizard like steps without errors
  • My web server is (include version): Nginx - nginx version: nginx/1.17.10 (Ubuntu)
  • The operating system my web server runs on is (include version):
    Ubuntu 20.04 LTS
    Codename:focal
  • My hosting provider, if applicable, is: DigitalOcean
  • I can login to a root shell on my machine (yes or no, or I don’t know): yes
  • I’m using a control panel to manage my site (no, or provide the name and version of the control panel): no
  • The version of my client is (e.g. output of certbot --version or certbot-auto --version if you’re using Certbot): certbot 0.40.0
1 Like

You’re not showing enough.
The port 80 config sends everything to 443.
Can we see all of the 443 config?
Can we also see the renewal conf file?

1 Like

Thanks for the prompt reply, I should have searched a bit more before sending this message; it seems that running ‘sudo certbot’ doesn’t correctly configure the certificate for Nginx, the correct command is ‘sudo certbot --Nginx’

I tried the command with the --Nginx parameter and it worked now

Thanks again

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.