SSL Certificate to change website to https

SYSTEM INFORMATION
OS type and version Ubuntu 20.04.3 LTS
Virtualmin version 6.2.2

I have a webmin with hostname virtualmin.xxx.com

Then I have 2 virtual servers: one called virtualmin and the other xxx.domain.com

xxx.domain.com is set to Default Website for IP address.

I would like to change xxx.domain.com to https://xxx.domain.com but when I go to Server Configuration - SSL Certificate - Let’s Encrypt and enter my domain I get the following error:

Web-based validation failed

Obtaining a new certificate
Performing the following challenges:
http-01 challenge for xxx.domain.com
http-01 challenge for www.xxx.domain.com
Using the webroot path /home/xxx/public_html for all unmatched domains.
Waiting for verification...
Challenge failed for domain www.xxx.domain.com
http-01 challenge for www.xxx.domain.com
Cleaning up challenges
Some challenges have failed.
IMPORTANT NOTES:
 - The following errors were reported by the server:

   Domain: www.xxx.domain.com
   Type:   dns
   Detail: DNS problem: NXDOMAIN looking up A for
   www.xxx.domain.com - check that a DNS record exists for this
   domain; DNS problem: NXDOMAIN looking up AAAA for
   www.xxx.domain.com - check that a DNS record exists for this
   domain

   DNS-based validation failed

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator manual, Installer None
Obtaining a new certificate
Performing the following challenges:
dns-01 challenge for www.xxx.domain.com
Running manual-auth-hook command: /etc/webmin/webmin/letsencrypt-dns.pl
Waiting for verification...
Challenge failed for domain www.xxx.domain.com
dns-01 challenge for www.xxx.domain.com
Cleaning up challenges
Running manual-cleanup-hook command: /etc/webmin/webmin/letsencrypt-cleanup.pl
Some challenges have failed.
IMPORTANT NOTES:
 - The following errors were reported by the server:

   Domain: www.xxx.domain.com
   Type:   dns
   Detail: DNS problem: NXDOMAIN looking up TXT for
   _acme-challenge.www.xxx.domain.com - check that a DNS record
   exists for this domain

Any help how I can solve this please?

Wherever you registered the domain name doesn’t have the proper DNS records, so Lets Encrypt can’t resolve the address to verify the domain.

I would guess that your Virtualmin installation isn’t doing your DNS. If it were, you wouldn’t have an issue as Virtulamin creates the necessary records when you create a virtual server.