I am trying to use a CNAME record instead of an A record, so I have the following setup:
On domain mktg.dev I have created a CNAME record k2mac.mktg.dev pointing to mktg-dev.k2mac.nl
On mktg-dev.k2mac.nl I have an A record pointing to the server IP: 3.66.118.132
On the host with IP: 3.66.118.132 there is an HAProxy using the http-01 method to obtain and renew certs.
This host runs other domains and has zero issues with the issuance of certificates when using A records, but for CNAME records it only works when the --dry-run parameter is enabled and then it fails without the --dry-run parameter:
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator standalone, Installer None
Obtaining a new certificate
IMPORTANT NOTES:
The dry run was successful.
root@hap-4-10 ~ # certbot certonly --standalone -d k2mac.mktg.dev --non-interactive --agree-tos --email yosu.cadilla@gmail.com --http-01-port=8888
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator standalone, Installer None
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for k2mac.mktg.dev
Waiting for verification...
Cleaning up challenges
Failed authorization procedure. k2mac.mktg.dev (http-01): urn:ietf:params:acme:error:connection :: The server could not connect to the client to verify the domain :: 3.66.118.132: Fetching http://k2mac.mktg.dev/.well-known/acme-challenge/EPTBf8klz9ahNQaBmCugzxUDo4lCL02g8KNMuqluNM0: Connection reset by peer
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. Additionally, please check that
your computer has a publicly routable IP address and that no
firewalls are preventing the server from communicating with the
client. If you're using the webroot plugin, you should also verify
that you are serving files from the webroot path you provided.
Very confused by this result, any pointers greatly appreciated.
Debugging standalone is harder. It sometimes helps to add--debug-challenges -v to the certbot command. This will pause certbot and wait for a challenge. We can then test comms to it if you leave it paused.
We can try that but let us know about your routing for http requests to your standalone on port 8888
I have removed all the parameters unrelated to certbot...
This server hosts several domains, each one has a certificate previously issued from this HAProxy server, everything runs smoothly, always, for years, if we use an A record.
It is now that I am testing CNAME records that the issue appears. When issuing the command with --dry-run, it works perfectly.
What is the difference when running a command with or without this parameter?
The --dry-run success is probably a cached authorization + really old version of Certbot.
I agree that the accept-proxy is probably the culprit. I think that changes the protocol from HTTP to the Proxy protocol. Just bind *:80 should be fine.
Debugging standalone is harder. It sometimes helps to add --debug-challenges -v to the certbot command.
Thanks for the tip, running the command with those parameters I have found this:
Performing the following challenges:
http-01 challenge for k2mac.mktg.dev
Successfully bound to :8888 using IPv6
Certbot wasn't able to bind to :8888 using IPv4, this is often expected due to the dual stack nature of IPv6 socket implementations.
Waiting for verification...
I don't think the binding warning is a problem. I still get 'reset by peer" for any request. I should see something else if http request was reaching the certbot standalone while it is waiting
Upgrading the packages seems to have solved the problem.
@MikeMcQ
About the "reset by peer" messages: There was no actual server/service listening on the destination specified on HAProxy, so I added an apache server with an app.
Now I am not sure what fixed the problem was the package upgrade or the valid destination.
Anyhow, I have got a valid certificate, thank you very much to the both of you!!