Certbot failed to authenticate some domains (authenticator: nginx)

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. crt.sh | 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: backend.catalinaortega.me

I ran this command: sudo certbot --nginx -v

It produced this output:

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator nginx, Installer nginx

Which names would you like to activate HTTPS for?
We recommend selecting either all domains, or all domains in a VirtualHost/server block.


1: backend.catalinaortega.me


Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter 'c' to cancel):
Requesting a certificate for backend.catalinaortega.me
Performing the following challenges:
http-01 challenge for backend.catalinaortega.me
Waiting for verification...
Challenge failed for domain backend.catalinaortega.me
http-01 challenge for backend.catalinaortega.me

Certbot failed to authenticate some domains (authenticator: nginx). The Certificate Authority reported these problems:
Domain: backend.catalinaortega.me
Type: unauthorized
Detail: 18.116.142.217: Invalid response from http://backend.catalinaortega.me/.well-known/acme-challenge/CiXc1S5EfeiyjrOlZOw5NP8ow9xUh_eNjEE8QD20Kho: 404

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.

Cleaning up challenges

My web server is (include version): nginx version: nginx/1.18.0 (Ubuntu)

The operating system my web server runs on is (include version): Ubuntu 20

My hosting provider, if applicable, is: aws

I can login to a root shell on my machine (yes or no, or I don't know): I dont know

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 2.10.0

Welcome @catalinaortegacalder

When I query your domain I get a response from a uvicorn server. Is that yours?

If not, check the IP in your DNS to make sure it is correct. If it is, can you please explain how nginx and uvicorn work together?

Request to: backend.catalinaortega.me/18.116.142.217, Result: [Address=18.116.142.217,Address Type=IPv4,Server=uvicorn

2 Likes

yes it is!

my api is made with fast api. I used uvicorn.

I am running my api on a docker container and exposing it with nginx

Is nginx running in your host?

Can you show output of this. An upper case T is essential. The output will be long

sudo nginx -T
3 Likes

sudo nginx -T

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
# configuration file /etc/nginx/nginx.conf:
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
        worker_connections 768;
        # multi_accept on;
}

http {

        ##
        # Basic Settings
        ##

        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;
        # server_tokens off;

        # server_names_hash_bucket_size 64;
        # server_name_in_redirect off;

        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        ##
        # SSL Settings
        ##

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
        ssl_prefer_server_ciphers on;

        ##
        # Logging Settings
        ##

        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;

        ##
        # Gzip Settings
        ##

        gzip on;

        # gzip_vary on;
        # gzip_proxied any;
        # gzip_comp_level 6;
        # gzip_buffers 16 8k;
        # gzip_http_version 1.1;
        # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

        ##
        # Virtual Host Configs
        ##

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
}


#mail {
#       # See sample authentication script at:
#       # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
#       # auth_http localhost/auth.php;
#       # pop3_capabilities "TOP" "USER";
#       # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
#       server {
#               listen     localhost:110;
#               protocol   pop3;
#               proxy      on;
#       }
#
#       server {
#               listen     localhost:143;
#               protocol   imap;
#               proxy      on;
#       }
#}

# configuration file /etc/nginx/modules-enabled/50-mod-http-image-filter.conf:
load_module modules/ngx_http_image_filter_module.so;

# configuration file /etc/nginx/modules-enabled/50-mod-http-xslt-filter.conf:
load_module modules/ngx_http_xslt_filter_module.so;

# configuration file /etc/nginx/modules-enabled/50-mod-mail.conf:
load_module modules/ngx_mail_module.so;

# configuration file /etc/nginx/modules-enabled/50-mod-stream.conf:
load_module modules/ngx_stream_module.so;

# configuration file /etc/nginx/mime.types:

types {
    text/html                             html htm shtml;
    text/css                              css;
    text/xml                              xml;
    image/gif                             gif;
    image/jpeg                            jpeg jpg;
    application/javascript                js;
    application/atom+xml                  atom;
    application/rss+xml                   rss;

    text/mathml                           mml;
    text/plain                            txt;
    text/vnd.sun.j2me.app-descriptor      jad;
    text/vnd.wap.wml                      wml;
    text/x-component                      htc;

    image/png                             png;
    image/tiff                            tif tiff;
    image/vnd.wap.wbmp                    wbmp;
    image/x-icon                          ico;
    image/x-jng                           jng;
    image/x-ms-bmp                        bmp;
    image/svg+xml                         svg svgz;
    image/webp                            webp;

    application/font-woff                 woff;
    application/java-archive              jar war ear;
    application/json                      json;
    application/mac-binhex40              hqx;
    application/msword                    doc;
    application/pdf                       pdf;
    application/postscript                ps eps ai;
    application/rtf                       rtf;
    application/vnd.apple.mpegurl         m3u8;
    application/vnd.ms-excel              xls;
    application/vnd.ms-fontobject         eot;
    application/vnd.ms-powerpoint         ppt;
    application/vnd.wap.wmlc              wmlc;
    application/vnd.google-earth.kml+xml  kml;
    application/vnd.google-earth.kmz      kmz;
    application/x-7z-compressed           7z;
    application/x-cocoa                   cco;
    application/x-java-archive-diff       jardiff;
    application/x-java-jnlp-file          jnlp;
    application/x-makeself                run;
    application/x-perl                    pl pm;
    application/x-pilot                   prc pdb;
    application/x-rar-compressed          rar;
    application/x-redhat-package-manager  rpm;
    application/x-sea                     sea;
    application/x-shockwave-flash         swf;
    application/x-stuffit                 sit;
    application/x-tcl                     tcl tk;
    application/x-x509-ca-cert            der pem crt;
    application/x-xpinstall               xpi;
    application/xhtml+xml                 xhtml;
    application/xspf+xml                  xspf;
    application/zip                       zip;

    application/octet-stream              bin exe dll;
    application/octet-stream              deb;
    application/octet-stream              dmg;
    application/octet-stream              iso img;
    application/octet-stream              msi msp msm;

    application/vnd.openxmlformats-officedocument.wordprocessingml.document    docx;
    application/vnd.openxmlformats-officedocument.spreadsheetml.sheet          xlsx;
    application/vnd.openxmlformats-officedocument.presentationml.presentation  pptx;

    audio/midi                            mid midi kar;
    audio/mpeg                            mp3;
    audio/ogg                             ogg;
    audio/x-m4a                           m4a;
    audio/x-realaudio                     ra;

    video/3gpp                            3gpp 3gp;
    video/mp2t                            ts;
    video/mp4                             mp4;
    video/mpeg                            mpeg mpg;
    video/quicktime                       mov;
    video/webm                            webm;
    video/x-flv                           flv;
    video/x-m4v                           m4v;
    video/x-mng                           mng;
    video/x-ms-asf                        asx asf;
    video/x-ms-wmv                        wmv;
    video/x-msvideo                       avi;
}

# configuration file /etc/nginx/sites-enabled/api.conf:
# https://docs.nginx.com/nginx/admin-guide/web-server/reverse-proxy/

# Example of NGINX configured as a reverse-proxy server with load balancer.
# upstream loadbalancername {
#     # https://www.nginx.com/blog/choosing-nginx-plus-load-balancing-techniques
#     server localhost:3000;
#     server localhost:3001;
#     server localhost:3002;
# }

# server {
#     listen 80;
#     server_name localhost www.example.com example.com;
#     location / {
#         # To pass a request to an HTTP proxied server
#         proxy_pass http://loadbalancername;

#         # NGINX redefines two header fields in proxied requests,
#         # “Host” and “Connection”, and eliminates the header
#         # fields whose values are empty strings

#         # https://www.nginx.com/resources/wiki/start/topics/examples/forwarded/
#         proxy_set_header Host $host;
#         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

#         # http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_redirect
#         # To not redirect, but to proxy
#         proxy_redirect off;
#     }
# }

# Example of NGINX configured as a reverse-proxy WITHOUT load balancer.
# server {
#     listen 80;
#     server_name www.example2.com example2.com;
#     location / {
#         proxy_pass http://localhost:3000;

#         # https://www.nginx.com/resources/wiki/start/topics/examples/forwarded/
#         proxy_set_header Host $host;
#         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

#         # http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_redirect
#         # To not redirect, but to proxy
#         proxy_redirect off;
#     }
# }

# Example of NGINX configured as web server serving an static site.
#server {
#    listen 80;
#    server_name www.example3.com example3.com;
#    location / {
#        root /home/user/static-site/;
#    }
#}# https://docs.nginx.com/nginx/admin-guide/web-server/reverse-proxy/

# Example of NGINX configured as a reverse-proxy server with load balancer.
# upstream loadbalancername {
#     # https://www.nginx.com/blog/choosing-nginx-plus-load-balancing-techniques
#     server localhost:3000;
#     server localhost:3001;
#     server localhost:3002;
# }

# server {
#     listen 80;
#     server_name localhost www.example.com example.com;
#     location / {
#         # To pass a request to an HTTP proxied server
#         proxy_pass http://loadbalancername;

#         # NGINX redefines two header fields in proxied requests,
#         # “Host” and “Connection”, and eliminates the header
#         # fields whose values are empty strings

#         # https://www.nginx.com/resources/wiki/start/topics/examples/forwarded/
#         proxy_set_header Host $host;
#         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

#         # http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_redirect
#         # To not redirect, but to proxy
#         proxy_redirect off;
#     }
# }

 #Example of NGINX configured as a reverse-proxy WITHOUT load balancer.
 server {
     listen 8081;
     server_name catalinaortega.me;
     location / {
         proxy_pass http://localhost:80;

         # https://www.nginx.com/resources/wiki/start/topics/examples/forwarded/
         proxy_set_header Host $host;
         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

         # http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_redirect
         # To not redirect, but to proxy
         proxy_redirect off;
     }
 }

# Example of NGINX configured as web server serving an static site.
#server {
#    listen 80;
#    server_name backend.catalinaortega.me;
#    location / {
#        root /home/user/static-site/;
#    }
#}
1 Like

nginx is running,

sudo systemctl status nginx.service
â—Ź nginx.service - A high performance web server and a reverse proxy server
     Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
     Active: active (running) since Sat 2024-04-20 13:35:18 UTC; 2h 8min ago
       Docs: man:nginx(8)
    Process: 38650 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
    Process: 38651 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
   Main PID: 38652 (nginx)
      Tasks: 2 (limit: 1126)
     Memory: 2.5M
     CGroup: /system.slice/nginx.service
             ├─38652 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
             └─38685 nginx: worker process

Apr 20 13:35:18 ip-172-31-34-8 systemd[1]: Starting A high performance web server and a reverse proxy server...
Apr 20 13:35:18 ip-172-31-34-8 systemd[1]: Started A high performance web server and a reverse proxy server.
1 Like

Is it running in a container or your host?

Can you edit your post with the nginx -T output to place 3 backticks before and after the output? That will preserve the formatting. Some key info was lost. Sorry. So like this:
```
nginx -T output
```

Or, if it is easier upload the /var/log/letsencrypt/letsencrypt.log file from a try that failed with the 404 error

1 Like

It doesn't look like nginx is first in line at port 80.

1 Like

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