admin管理员组

文章数量:1314308

I’m trying to secure my website by obtaining an SSL certificate through Certbot and Nginx, but I’m encountering the following error:

Certbot failed to authenticate some domains (authenticator: nginx). The Certificate Authority reported these problems:
  Domain: example
  Type:   unauthorized
  Detail: 2a02:4780:6:1510:0:2337:755:2: Invalid response from http:// example/.well-known/acme-challenge/tPL5vLsp-E6o247oFXb3eSty8pqegHALTzlEdSvEvH8: 404

  Domain: www.example
  Type:   unauthorized
  Detail: 2a02:4780:6:1510:0:2337:755:2: Invalid response from http://www. example/.well-known/acme-challenge/v6_o2BKvPZ3IHQjUK0U2jhyXgxkkQWubG0F0i5dbhKw: 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.

I’m using the following server configuration on my Nginx:

sudo nano /etc/nginx/sites-available/default
server {
        listen 80  default_server;
        listen [::]:80 default_server;
        root /usr/share/nginx/html;
        server_name _;
        location /.well-known/acme-challenge {
         root /usr/share/nginx/html;
        }
        location / {
           return 301 https://$host$request_uri;
        }
}
sudo nano /etc/nginx/sites-available/example
server {
   listen 80 default_server;
   listen [::]:80 default_server ipv6only=on;
   server_name example www.example;
   return 301 https://$server_name$request_uri;
}
sudo nano /etc/nginx/sites-available/myapp
server {
        server_name example;
        location / {
                proxy_pass http://localhost:3838;
                proxy_redirect / $scheme://$http_host/;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
                proxy_read_timeout 20d;
                proxy_buffering off;
        }
}

I ran sudo nginx -t, and it reports the following warnings:

2025/01/30 13:23:35 [warn] 5442#5442: conflicting server name "example" on 0.0.0.0:80, ignored
2025/01/30 13:23:35 [warn] 5442#5442: conflicting server name " example" on 0.0.0.0:80, ignored

I then tried obtaining the SSL certificate with

sudo certbot --nginx -d example -d www.example

command, but Certbot fails with an unauthorized error.

本文标签: Invalid response from http to https nginxStack Overflow