Caddy initial config question

i have central domain (sample.com) after registration create one subdomain for each user like (ada.sample.com)

then user can change ada.sample.com to >>> doain.com or my.doain.com or other user can use self domain like dxa.com , … unlimited custome domain or subdomains

How to define the settings of these states?

sample.com *.sample.com {

	root * /var/www/public
	file_server
	encode gzip 
	php_fastcgi unix//run/php/php8.0-fpm.sock

	tls {
		dns cloudflare "_H_vQajBjTvG_G-nJtF8UdZPr0kR8i8"
		resolvers 1.1.1.1
	}

}

in same this tutorial Serving tens of thousands of domains over HTTPS with Caddy use this syntx

https:// {
    tls {
        on_demand
    }
    reverse_proxy localhost:9000
}

Now how do you combine these two?