Skip to content

beget: erases A and MX records for the root domain (CNAME wildcard) #2774

@tannisroot

Description

@tannisroot

Welcome

  • Yes, I'm using a binary release within the two latest releases.
  • Yes, I've searched for similar issues on GitHub and didn't find any.
  • Yes, I've included all information below (version, config, etc).

What did you expect to see?

Since Traefik relies on lego for certificate management, I figured I would file an issue about it here as well.
I've filed the following ticket with Beget.com:

Hello, I want to configure the acquiring and auto-renewal of Let's Encrypt certificates via Traefik.
I added the following configuration to Traefik:

certificatesResolvers:
  beget:
    acme:
      email: "hidden"
      storage: /var/traefik/certs/beget-acme.json
      caServer: "https://acme-v02.api.letsencrypt.org/directory"
      dnsChallenge:
        provider: beget
        resolvers:
          - "1.1.1.1:53"
          - "8.8.8.8:53"

I also passed the BEGET_USER and BEGET_PASSWORD variables with my username and a pre-created API password.
In my Beget account, I went to the DNS section and changed the root (@) A record to my server's IP, and also added a Wildcard (*) record pointing to CNAME with the root record. I need this because there are many services running on the server with individual subdomains.
I start Traefik, and there seem to be no errors, but when I go to the DNS panel in Beget, I see that all records except TXT have disappeared from the root domain (@).
I restore it to how it was, change the CNAME for the wildcard * subdomain to an A record with the same IP as the A record for the root domain.
I had this configuration in Cloudflare before and everything worked fine.
I restart Traefik, and an error appears:

2025-12-30T02:17:43+03:00 ERR Unable to obtain ACME certificate for domains error="unable to generate a certificate for the domains [immich.hidden]: error: one or more domains had a problem:\n[immich.hidden] [immich.hidden] acme: error presenting token: beget: get TXT records: API answer error: METHOD_FAILED: Failed to get DNS records\n" ACME CA=https://acme-v02.api.letsencrypt.org/directory acmeCA=https://acme-v02.api.letsencrypt.org/directory domains=["immich.hidden"] providerName=beget.acme routerName=immich@docker rule=Host(`immich.hidden`)

To which I've received the following:

The problem arises due to the peculiarities of the Beget API:

When calling changeRecords for the root domain (@), you need to transfer all existing A, MX, and TXT records in their entirety, otherwise the rest will be deleted, leaving only TXT for the ACME challenge.

The Traefik provider (plugin) “beget” does not take this into account and tries to get/update only TXT, which leads to an error:

METHOD_FAILED: Failed to get DNS records

However, it is not clear to me why the root domain is even touched at all. Shouldn't lego create a subdomain for a particular certificate it wants to create, like _acme-challenge.DOMAIN, instead of messing with the root?

What did you see instead?

Root DNS records remain intact and certification acquisition to complete succefully

How do you use lego?

Through Traefik

Reproduction steps

  1. Have a domain with Beget, have the wildcard subdomain set to CNAME with value of the root domain
  2. Add the following to the Traefik config:
      beget:
        acme:
          email: "hidden"
          storage: /var/traefik/certs/beget-acme.json
          caServer: "https://acme-v02.api.letsencrypt.org/directory"
          dnsChallenge:
            provider: beget
            resolvers:
              - "1.1.1.1:53"
              - "8.8.8.8:53"
  3. Create an API Password in Beget account, set BEGET_USERNAME and BEGET_PASSWORD.
  4. Start Traefik
  5. Check DNS records in Beget panel - the A, MX records are erased.
  6. Reset DNS records, change wildcard subdomain to A record.
  7. Start Traefik
  8. Get the error

Effective version of lego

v4.30.1 (bundled with Traefik)

Logs

Details
2025-12-30T02:17:43+03:00 ERR Unable to obtain ACME certificate for domains error="unable to generate a certificate for the domains [immich.hidden]: error: one or more domains had a problem:\n[immich.hidden] [immich.hidden] acme: error presenting token: beget: get TXT records: API answer error: METHOD_FAILED: Failed to get DNS records\n" ACME CA=https://acme-v02.api.letsencrypt.org/directory acmeCA=https://acme-v02.api.letsencrypt.org/directory domains=["immich.hidden"] providerName=beget.acme routerName=immich@docker rule=Host(`immich.hidden`)

Go environment (if applicable)

Details
$ go version && go env
# paste output here

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions