Hello,
I was trying to use certbot to create certificates for both api.auto-nuoma.lt and auto-nuoma.lt. Both of them are on the same server which has an IPv4 of 194.31.55.108 and IPv6 of 2a02:4780:c:8c89::1. I am using nginx as a reverse proxy to route traffic to my internal node.js and .net applications.
Unfortunately, the certbot fails to authorize auto-nuoma.lt and throws and error of
Certbot failed to authenticate some domains (authenticator: nginx). The Certificate Authority reported these problems:
Domain: auto-nuoma.lt
Type: unauthorized
Detail: 2a02:4780:c:8c89::1: Invalid response from http://auto-nuoma.lt/.well-known/acme-challenge/GvcSONag5C8A3mRMZttY0aDYE_SdiON5H16dJJs5yMs: 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 managed to hack my way around it, I removed nginx config file for api.auto-nuoma.lt, and then ran
sudo certbot --nginx
Then selected auto-nuoma.lt domain. When it was alone - everything went well and I managed to get a certificate for it. After that I added back the api.auto-nuoma.lt nginx config file and I was happy with my fix.
But that is not the end, I tried to renew the certificates and got the same problem
Certbot failed to authenticate some domains (authenticator: nginx). The Certificate Authority reported these problems:
Domain: auto-nuoma.lt
Type: unauthorized
Detail: 2a02:4780:c:8c89::1: Invalid response from http://auto-nuoma.lt/.well-known/acme-challenge/GvcSONag5C8A3mRMZttY0aDYE_SdiON5H16dJJs5yMs: 404
Any ideas why this is happening and how to fix it? I would like to get a benefit of automatic certificate renewal process.
The operating system my web server runs on is (include version): Ubuntu 22.04.3 LTS
The version of my client is (e.g. output of certbot --version or certbot-auto --version if you're using Certbot): certbot 2.8.0
From the error msg shown above and the fact that LE prefers IPv6 over IPv4...
I would guess that your nginx vhost [for this specific domain] isn't using/listening on IPv6.
Other parts of nginx [serving other vhosts] may be doing IPv6 correctly.
Thanks guys, for such a quick response. I managed to track it down with your suggestions. Turns out nginx for auto-nuoma.lt domain (which was failing) was not listening on IPv6, only on IPv4. Just added one liner into the config to listen for IPv6 as well and certbot went through without any issues. Thanks guys for help.
TLDR: Issue is solved, nginx was not listening on IPv6.