Unable to make certbot/nginx certificate on ubuntu 20.04

Please fill out the fields below so we can help you better. Note: you must provide your domain name to get help. Domain names for issued certificates are all made public in Certificate Transparency logs (e.g. https://crt.sh/?q=example.com), so withholding your domain name here does not increase secrecy, but only makes it harder for us to provide help.

My domain is:
exmapleapi.com

I ran this command:
sudo certbot --nginx -d www.exampleapi.com

It produced this output:
Challenge failed for domain www.exampleapi.com
http-01 challenge for www.exampleapi.com
Cleaning up challenges Some challenges have failed.

  • The following errors were reported by the server:
    Domain: www.exampleapi.com
    Type: unauthorized
    Detail: 12.127.423.123: Invalid response from
    Loading...
    challenge/S9rQiQXAa_92vMoC9ITqSxeoqvbrLYmF2Ma11T8g1w4:
    403
    To fix these errors, please make sure that your domain name was
    entered correctly and the DNS A/AAAA record(s) for that domain
    contain(s) the right IP address.

My web server is (include version):
nginx 1.25.4
The operating system my web server runs on is (include version):
ubuntu 20.04

My hosting provider, if applicable, is:
godaddy
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):

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

  server {
          server_name example.com http://example.com/ exampleapi.com 
          http://exampleapi.com/ www.example.com http://www.example.com/ 
          www.exampleapi.com http://www.exampleapi.com/;
          location / {
          root /var/www/example.com/html/;
          index index.html index.htm index.nginx-debian.html;
          }

          location /api {
          proxy_pass https://exampleapi.com https://exampleapi.com/;
          proxy_set_header Host exampleapi.com http://exampleapi.com/;
          }

          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 = example.com http://example.com/ {
          return 301 https://$host$request_uri;
          } # managed by Certbot

          listen 80;
          listen [::]:80;
          server_name example.com http://example.com/ exampleapi.com 
          http://exampleapi.com/ www.exampleapi.com http://www.exampleapi.com 
          www.example.com http://www.example.com/;
          return 404; # managed by Certbot
          }

That is not valid syntax. Try running nginx -t

Do those files exist? Because those files are usually only created after a successful Certbot run. You cannot refer to non-existent files in nginx conf.

That is not valid syntax either. You should probably spend some time at nginx documentation

2 Likes

I have no idea where this http://exampleapi.com/... came from in the question but i do not have this in my config file. It looks like this:
server_name e-selector.com e-selectorapi.com www.e-selectorapi.com www.e-selector.com;

the test is successfull no syntax error. It seems like it is no longer possible to edit the question once u permit right?

I managed to make ssl certificate for two domains around 1 year ago but now i got another domain and wanted to make ssl certificate for a new one thats why it does not work.
example.com is for the front end and exampleapi.com for the backend.
the backend domain is new one exampleapi.com and i am trying to add new ssl cert for this one which does not work.

This last case u make is also not related to the actuall problem bc the actuall syntax looks like this: (unfortunatly i can not edit the question once permited)

if ($host = example.com) {
return 301 https://$host$request_uri;
}

This is correct syntax. So your remarks are right however non of them are actually related to the Problem why it does give that error. Even if i had those Syntaxs errors the actuall error message which i posted woud have been related to syntex and not to the issue. You could easily make assumptions that those are mistakes made during the question description

Yes, I could but you would be surprised at the kinds of things we see :slight_smile: Making assumptions like that often lead to lots of confusion.

When posting config text you could use the "Preformatted Text" option to preserve the original.

So, let's ignore the syntax. We will need to know your actual domain to provide specific help. The error message from your very old Certbot v0.40 does not provide enough info to even begin to suggest anything. The "403" in the error is just too common and we need at least the "subreason" provided by later versions.

You should change to the snap version of Certbot. Ubuntu easily supports that

2 Likes

Okey I just updated certbot and now
certbot --version is:
certbot 3.0.1

my actuall domains are frontend: e-selector.com and backend: e-selectorapi.com

Okay good.

What does this show? It is only a test

sudo certbot certonly --nginx --dry-run -d e-selector.com -d e-selectorapi.com
1 Like

Certbot failed to authenticate some domains (authenticator: nginx). The Certificate Authority reported these problems:
Domain: e-selector.com
Type: unauthorized
Detail: During secondary validation: 15.197.142.173: Invalid response from http://e-selector.com/.well-known/acme-challenge/pTKvGJQcFS5ZoTueObmTxZ94iGzUcIyYG7aO2Xau2lY: 403

Domain: e-selectorapi.com
Type: unauthorized
Detail: 15.197.225.128: Invalid response from http://e-selectorapi.com/.well-known/acme-challenge/yRUF_6Co5j6oFibok77UyMOwDsRzfJrPCml6NIss_KQ: 403

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.

Some challenges have failed.
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.

Oh, you have 3 IP addresses in your DNS. Looks like you had a "Domain Forwarding" feature setup. Either now or in the past.

Your DNS should just have the one public IP address for your nginx server.

e-selector.com.         600     IN      A       91.64.135.180
e-selector.com.         600     IN      A       15.197.142.173
e-selector.com.         600     IN      A       3.33.152.147

It is funny coincidence. I saw one just like this earlier today with Wild West Domains registration (a part of GoDaddy I think).

Anyway, please see this post for further help

1 Like